import torch


def compute_graph_dists(locations: torch.Tensor) -> torch.Tensor:
    """Compute the distance given a locations vector.

    Args:
        locations (torch.Tensor): Vector of locations

    Returns:
        torch.Tensor: N-by-N distance matrix
    """
    return torch.cdist(locations, locations, p=2.0).squeeze()