def normalize(samples):
    """Normalize samples by dividing by the norm taken over all samples.
    
    Args:
        samples (~torch.Tensor): Tensor of shape :math:`(*, N, F)` where
            :math:`*` means any number of additional dimensions,
            :math:`N` is the number of samples and :math:`F` is the number
            of features per sample.
    
    Returns:
        ~torch.Tensor: Normalized tensor of same shape as :attr:`samples`.
    """
    return samples / samples.norm(dim=-2, keepdim=True)