code: def maybe_get_avg_of_avgs(
      accuracy_per_sample, sample_labels, avg_of_avgs, return_per_class
  ):
      if avg_of_avgs or return_per_class:
          unique_labels = get_unique_labels(sample_labels)
          mask = c_f.torch_all_from_dim_to_end(
              sample_labels == unique_labels.unsqueeze(1), 2
          )
          mask = torch.t(mask)
          acc_sum_per_class = torch.sum(
              accuracy_per_sample.unsqueeze(1) * mask, dim=0
          )
          mask_sum_per_class = torch.sum(mask, dim=0)
          average_per_class = acc_sum_per_class / mask_sum_per_class
          if return_per_class:
              return average_per_class.cpu().tolist()
          return torch.mean(average_per_class).item()
      return torch.mean(accuracy_per_sample).item()
  
imports: import torch
  from sklearn.metrics import adjusted_mutual_info_score, normalized_mutual_info_score
  from .None import common_functions
  from .inference import FaissKMeans, FaissKNN
label_desc: Use image node_id 2 for calling a global function with example usage: maybe_get_avg_of_avgs(accuracy_per_sample, sample_labels, avg_of_avgs, return_per_class) and returns: torch, torch, average_per_class