import torch


def _(points: torch.Tensor, indices: torch.Tensor) -> torch.Tensor:
    """Computes batched tour distance.
    points should have dims (tour_len, batch, 2)
    indices should have dims (tour_len + 1, batch)
    """
    batch_arange = torch.arange(points.shape[1], device=points.device)
    # NOTE: indices are 1-indexed
    curr = points[indices[:-1] - 1, batch_arange]
    next_ = points[indices[1:] - 1, batch_arange]
    return torch.sum(torch.sqrt(torch.sum((next_ - curr) ** 2, dim=2)), dim=0)