class_docstr: A container class for metrics passed to `Model.compile`.
class_docstr_tok: ["A","container","class","for","metrics","passed","to","`","Model.compile","`","."]
docstr: One-time setup of metric objects.
code: def build(self, y_pred, y_true):
      """One-time setup of metric objects."""
      super(MetricsContainer, self).build(y_pred)
  
      self._metrics = self._maybe_broadcast_to_outputs(
          y_pred, self._metrics
      )
      self._metrics = self._conform_to_outputs(y_pred, self._metrics)
  
      self._weighted_metrics = self._maybe_broadcast_to_outputs(
          y_pred, self._weighted_metrics
      )
      self._weighted_metrics = self._conform_to_outputs(
          y_pred, self._weighted_metrics
      )
  
      # Standardize on tuple since `tf.data` turns lists into `Tensor`s.
      y_pred = nest.list_to_tuple(y_pred)
      y_true = nest.list_to_tuple(y_true)
      self._metrics = nest.list_to_tuple(self._metrics)
      self._weighted_metrics = nest.list_to_tuple(
          self._weighted_metrics
      )
  
      # Convert to `Metric` objects, potentially disambiguating based on output
      # properties.
      self._metrics = nest.map_structure_up_to(
          y_pred,
          self._get_metric_objects,
          self._metrics,
          y_true,
          y_pred,
      )
      self._weighted_metrics = nest.map_structure_up_to(
          y_pred,
          self._get_metric_objects,
          self._weighted_metrics,
          y_true,
          y_pred,
      )
  
      self._metrics = nest.flatten_up_to(
          y_pred, self._metrics, check_types=False
      )
      self._weighted_metrics = nest.flatten_up_to(
          y_pred, self._weighted_metrics, check_types=False
      )
  
      # Assumes metrics, weighted_metrics have been flattened up to outputs.
      #
      # If we are loading a model that has been already serialized, we do not
      # want to re-apply any pre-processing metric renaming steps.
      if not self._from_serialized:
          self._set_metric_names()
      self._create_ordered_metrics()
      self._built = True
  
imports: import copy
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.keras import losses
  from tensorflow.python.keras import metrics
  from tensorflow.python.keras.utils import generic_utils
  from tensorflow.python.keras.utils import losses_utils
  from tensorflow.python.keras.utils import tf_utils
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 5 for calling the MetricsContainer obj's underlying member method code with example usage: obj.build(y_pred, y_true) without return types