code: def _get_triplet_mask(labels):
      # Check that i, j and k are distinct
      indices_equal = torch.eye(
          labels.size(0), dtype=torch.bool, device=labels.device
      )
      indices_not_equal = ~indices_equal
      i_not_equal_j = indices_not_equal.unsqueeze(2)
      i_not_equal_k = indices_not_equal.unsqueeze(1)
      j_not_equal_k = indices_not_equal.unsqueeze(0)
  
      distinct_indices = (i_not_equal_j & i_not_equal_k) & j_not_equal_k
  
      label_equal = labels.unsqueeze(0) == labels.unsqueeze(1)
      i_equal_j = label_equal.unsqueeze(2)
      i_equal_k = label_equal.unsqueeze(1)
  
      valid_labels = ~i_equal_k & i_equal_j
  
      return valid_labels & distinct_indices
  
file_path: vision/references/similarity/loss.py
imports: import torch
  import torch.nn
label_desc: Use image node_id 3 for calling a global function with example usage: _get_triplet_mask(labels) and returns: unknown