code: def convert_to_weights(indices_tuple, labels, dtype, using_ref=False):
      """
      Returns a weight for each batch element, based on
      how many times they appear in indices_tuple.
      """
      weights = torch.zeros(labels.shape[0], device=labels.device)
      weights = c_f.to_dtype(weights, dtype=dtype)
      if (indices_tuple is None) or (
          all(len(x) == 0 for x in indices_tuple)
      ):
          return weights + 1
      if using_ref:
          # if using ref, then only the anchors refer to the query set
          indices = get_anchors(indices_tuple)
      else:
          indices = torch.cat(indices_tuple, dim=0)
      indices, counts = torch.unique(indices, return_counts=True)
      weights[indices] = c_f.to_dtype(counts, dtype=dtype) / torch.max(
          counts
      )
      return weights
  
imports: import math
  import numpy
  import torch
  from .None import common_functions
label_desc: Use image node_id 14 for calling a global function with example usage: convert_to_weights(indices_tuple, labels, dtype, using_ref) and returns: weights, unknown