import torch


def normalize(x: torch.Tensor) -> torch.Tensor:
    """Normalizes a vector with its L2-norm.

    Args:
        x: The vector to be normalized.

    Returns:
        The normalized vector of the same shape.
    """
    norm = x.pow(2).sum(1, keepdim=True).pow(1.0 / 2)
    out = x.div(norm)
    return out