code: def _macro_average_sub_keys(
      sub_key: Optional[metric_types.SubKey],
      class_weights: Dict[int, float],
  ) -> Iterable[metric_types.SubKey]:
      """Returns sub-keys required in order to compute macro average sub-key.
  
      Args:
        sub_key: SubKey associated with macro_average or weighted_macro_average.
        class_weights: Class weights associated with sub-key.
  
      Raises:
        ValueError: If invalid sub-key passed or class weights required but not
          passed.
      """
      if not sub_key:
          if not class_weights:
              raise ValueError(
                  "class_weights are required in order to compute macro average over "
                  "all classes: sub_key={}, class_weights={}".format(
                      sub_key, class_weights
                  )
              )
          return [
              metric_types.SubKey(class_id=i) for i in class_weights
          ]
      elif sub_key.top_k:
          return [
              metric_types.SubKey(k=i + 1) for i in range(sub_key.top_k)
          ]
      else:
          raise ValueError(
              "invalid sub_key for performing macro averaging: "
              "sub_key={}".format(sub_key)
          )
  
imports: import collections
  import importlib
  import json
  import re
  from typing import Any, Dict, FrozenSet, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Type, Union
  import tensorflow
  from tensorflow_model_analysis.metrics import aggregation
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import calibration
  from tensorflow_model_analysis.metrics import calibration_plot
  from tensorflow_model_analysis.metrics import confusion_matrix_metrics
  from tensorflow_model_analysis.metrics import confusion_matrix_plot
  from tensorflow_model_analysis.metrics import example_count
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import multi_class_confusion_matrix_plot
  from tensorflow_model_analysis.metrics import tf_metric_wrapper
  from tensorflow_model_analysis.metrics import weighted_example_count
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.utils import model_util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 18 for calling a global function with example usage: _macro_average_sub_keys(sub_key, class_weights) and returns: unknown, unknown