class_docstr: Combines compilable metric weights and computes result.
class_docstr_tok: ["Combines","compilable","metric","weights","and","computes","result","."]
code: def __init__(
      self,
      metric_configs: Dict[str, List[Dict[str, Any]]],
      loss_configs: Dict[str, List[Dict[str, Any]]],
      custom_objects: List[Tuple[str, str]],
      eval_config: Optional[config_pb2.EvalConfig],
      model_name: Optional[str],
      sub_key: Optional[metric_types.SubKey],
      aggregation_type: Optional[metric_types.AggregationType],
      class_weights: Dict[int, float],
      example_weighted: bool,
      desired_batch_size: Optional[int] = None,
  ):
      # Use parallel lists to store output_names and configs to guarantee
      # consistent ordering and for natural alignment with the accumulator where
      # lists are used instead of dicts for efficency.
      self._eval_config = eval_config
      self._model_name = model_name
      self._output_names = sorted(metric_configs)
      self._metric_configs = [
          metric_configs[n] for n in self._output_names
      ]
      self._loss_configs = [loss_configs[n] for n in self._output_names]
      self._custom_objects = custom_objects
      self._sub_key = sub_key
      self._aggregation_type = aggregation_type
      self._class_weights = class_weights
      self._example_weighted = example_weighted
      # True if the sub_key is part of the metric config already (i.e. top_k).
      self._sub_key_in_config = sub_key and sub_key.top_k is not None
      for cfg in itertools.chain.from_iterable(metric_configs.values()):
          if _get_config_value(_TOP_K_KEY, cfg) is None:
              self._sub_key_in_config = False
              break
      self._metrics = (
          None
      )  # type: Dict[str, List[tf.keras.metrics.Metric]]
      self._desired_batch_size = desired_batch_size
      self._batch_size_beam_metric = beam.metrics.Metrics.distribution(
          constants.METRICS_NAMESPACE,
          "keras_compilable_metrics_combine_batch_size",
      )
      self._total_input_byte_size_beam_metric = (
          beam.metrics.Metrics.distribution(
              constants.METRICS_NAMESPACE,
              "keras_compilable_metrics_combine_batch_bytes_size",
          )
      )
      self._num_compacts = beam.metrics.Metrics.counter(
          constants.METRICS_NAMESPACE, "num_compacts"
      )
  
imports: import collections
  import importlib
  import itertools
  from typing import Any, Dict, Iterable, List, Optional, Type, Tuple, Union
  import apache_beam
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import tf_metric_accumulators
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import model_util
label_desc: Use image node_id 1 to create a new _CompilableMetricsCombiner object from inherited base classes: beam with example: obj = _CompilableMetricsCombiner(metric_configs, loss_configs, custom_objects, eval_config, model_name, sub_key, aggregation_type, class_weights, example_weighted, desired_batch_size)