import torch


def _torch_normalize_vectors(rr):
    """Normalize surface vertices."""
    new_rr = rr.clone()
    size = torch.linalg.norm(rr, axis=1)
    mask = (size > 0)
    new_rr[mask] = rr[mask] / size[mask].unsqueeze(-1)
    return new_rr