def l2_norm(x):
    """
    Calculates the l2 norm of the input tensor.
    Args:
        x: tensor, any shape
           tensor to take the l2 norm of.

    Returns: float,
           l2 norm of the input

    """

    return x.view(-1).dot(x.view(-1))