code: def convert_to_triplets(
      indices_tuple, labels, ref_labels=None, t_per_anchor=100
  ):
      """
      This returns anchor-positive-negative triplets
      regardless of what the input indices_tuple is
      """
      if indices_tuple is None:
          if t_per_anchor == "all":
              return get_all_triplets_indices(labels, ref_labels)
          else:
              return get_random_triplet_indices(
                  labels, ref_labels, t_per_anchor=t_per_anchor
              )
      elif len(indices_tuple) == 3:
          return indices_tuple
      else:
          a1, p, a2, n = indices_tuple
          p_idx, n_idx = torch.where(a1.unsqueeze(1) == a2)
          return a1[p_idx], p[p_idx], n[n_idx]
  
imports: import math
  import numpy
  import torch
  from .None import common_functions
label_desc: Use image node_id 13 for calling a global function with example usage: convert_to_triplets(indices_tuple, labels, ref_labels, t_per_anchor) and returns: get_all_triplets_indices, get_random_triplet_indices, indices_tuple, a1,  p,  n