import torch


def complex_modulus(input_array):
    """Computes complex modulus.

        Parameters
        ----------
        input_array : tensor
            Input tensor whose complex modulus is to be calculated.
        Returns
        -------
        modulus : tensor
            Tensor the same size as input_array. modulus[..., 0] holds the
            result of the complex modulus, modulus[..., 1] = 0.

    """
    modulus = torch.zeros_like(input_array)
    modulus[..., 0] = torch.sqrt((input_array ** 2).sum(-1))
    return modulus