class_docstr: Base combiner for aggregating metrics for keras based models.
class_docstr_tok: ["Base","combiner","for","aggregating","metrics","for","keras","based","models","."]
code: def merge_accumulators(
      self,
      accumulators: Iterable[
          tf_metric_accumulators.TFMetricsAccumulator
      ],
  ) -> tf_metric_accumulators.TFMetricsAccumulator:
      accumulators = iter(accumulators)
      result = next(accumulators)
      # Finish processing last batch
      self._process_batch(result)
      for accumulator in accumulators:
          # Finish processing last batch
          self._process_batch(accumulator)
          # Merge the weights
          for metric_index in range(len(self._keys)):
              weights = accumulator.get_weights(0, metric_index)
              if weights is None:
                  # It is possible for beam to create an accumulator but pass no
                  # inputs to it resulting in empty weights. In theory all weights
                  # should be empty but we check on a per metric weights basis.
                  continue
              result.add_weights(0, metric_index, weights)
      return result
  
imports: import collections
  from itertools import chain
  from typing import Dict, Iterable, List, Optional
  import apache_beam
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  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
  from tensorflow_model_analysis.utils import util
label_desc: Use image node_id 10 for calling the _KerasCombiner obj's underlying member method code with example usage: obj.merge_accumulators(accumulators) and returns: result