def _get_anchor_negative_triplet_mask(labels):
    """Get a 2D mask where mask[a, n] is True iff a and n have different labels.
    Args:
        labels (torch.tensor): Labels with shape (batch_size)
    Returns:
        mask (torch.bool): Mask of shape (batch_size, batch_size)
    """
    # Use broadcasting to make the mask
    mask = ~(labels.unsqueeze(0) == labels.unsqueeze(1))

    return mask