import torch


def identity_like(z: torch.Tensor) -> torch.Tensor:
    """
    Return a complex identity of the shape of z, with the same type and device.

    Parameters
    ----------
    z : tensor
        Complex matrix of rank n

    Returns
    -------
    torch.Tensor
        Complex identity of rank n with zeros in the imaginary part
    """
    return torch.eye(z.shape[-1], dtype=z.dtype, device=z.device).expand_as(z)