class_docstr: Aggregates metrics using keras model.evaluate method.
class_docstr_tok: ["Aggregates","metrics","using","keras","model.evaluate","method","."]
code: def _update_state(
      self, accumulator: tf_metric_accumulators.TFMetricsAccumulator
  ):
      features = {}
      labels = {}
      example_weights = {}
      for i, output_name in enumerate(self._output_names):
          f, l, w = accumulator.get_inputs(i)
          if i == 0:
              features = util.merge_extracts(f)
          if not output_name and len(self._output_names) > 1:
              # The empty output_name for multi-output models is not used for inputs.
              continue
          labels[output_name] = np.array(l)
          weights = np.array(w)
          # TFv1 will not squeeze the weights, so must do manually
          if weights.shape[-1] == 1:
              weights = weights.squeeze(axis=-1)
          example_weights[output_name] = weights
      if len(self._output_names) == 1:
          # Single-output models don't use dicts.
          labels = next(iter(labels.values()))
          example_weights = next(iter(example_weights.values()))
      input_specs = model_util.get_input_specs(
          self._model, signature_name=None
      )
      inputs = model_util.get_inputs(features, input_specs)
      if inputs is None:
          raise ValueError(
              "unable to prepare inputs for evaluation: "
              f"input_specs={input_specs}, features={features}"
          )
      self._model.evaluate(
          x=inputs,
          y=labels,
          batch_size=util.batch_size(features),
          verbose=0,
          sample_weight=example_weights,
      )
  
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 5 for calling the _KerasEvaluateCombiner obj's underlying member method code with example usage: obj._update_state(accumulator) without return types