import torch


def real(z):
    """
    Returns the real part of pytorch tensor.

    Parameters
    ----------
    z : tensor
        Input.

    Returns
    -------
    tensor
        Output.

    """
    if torch.is_complex(z):
        return z.real
    else:
        return z