code: def get_relevance_mask(
      shape,
      gt_labels,
      ref_includes_query,
      label_counts,
  ):
      relevance_mask = torch.zeros(
          size=shape, dtype=torch.bool, device=gt_labels.device
      )
      count_per_query = torch.zeros(
          len(gt_labels), dtype=torch.long, device=gt_labels.device
      )
  
      for label, count in zip(*label_counts):
          matching_rows = torch.where(
              c_f.torch_all_from_dim_to_end(gt_labels == label, 1)
          )[0]
          max_column = count - 1 if ref_includes_query else count
          relevance_mask[matching_rows, :max_column] = True
          count_per_query[matching_rows] = max_column
      return relevance_mask, count_per_query
  
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 3 for calling a global function with example usage: get_relevance_mask(shape, gt_labels, ref_includes_query, label_counts) and returns: relevance_mask,  count_per_query