class_docstr: Accumulator for TF metrics.
  
  Attributes:
    inputs: Accumulated batch of inputs. The inputs are stored in a
      multi-dimensional list. The first dimension is used to index the
      associated output (for single-output models this will only have one item).
      The second dimension is used to store the args used by the combiner. For
      example the args might be a tf.Example if feeding a model or they might be
      (y_true, y_pred, example_weight) for calling update_state directly.
      Batching is done on the last dimension.
    weights: Accumulated weights. The weights are stored in a multi-dimensional
      list where the first dimension is used to index the associated output (for
      single-output models this will only have one item). The second dimension
      is used to store the accumulated weights for each metric associated with
      the output dimension.
    size_estimator: Batch size estimator.
    desired_batch_size: Desired batch size.
class_docstr_tok: ["Accumulator","for","TF","metrics",".","Attributes",":","inputs",":","Accumulated","batch","of","inputs",".","The","inputs","are","stored","in","a","multi-dimensional","list",".","The","first","dimension","is","used","to","index","the","associated","output","(","for","single-output","models","this","will","only","have","one","item",")",".","The","second","dimension","is","used","to","store","the","args","used","by","the","combiner",".","For","example","the","args","might","be","a","tf.Example","if","feeding","a","model","or","they","might","be","(","y_true",",","y_pred",",","example_weight",")","for","calling","update_state","directly",".","Batching","is","done","on","the","last","dimension",".","weights",":","Accumulated","weights",".","The","weights","are","stored","in","a","multi-dimensional","list","where","the","first","dimension","is","used","to","index","the","associated","output","(","for","single-output","models","this","will","only","have","one","item",")",".","The","second","dimension","is","used","to","store","the","accumulated","weights","for","each","metric","associated","with","the","output","dimension",".","size_estimator",":","Batch","size","estimator",".","desired_batch_size",":","Desired","batch","size","."]
docstr: Initializes accumulator using a list of metric counts per output.
  
  Args:
    input_counts: Number of inputs associated with each output index.
    metric_counts: Number of metrics associated with each output index.
    size_estimator_fn: Function to use for estimating the size of the inputs.
    desired_batch_size: FOR TESTING ONLY.
docstr_tok: ["Initializes","accumulator","using","a","list","of","metric","counts","per","output",".","Args",":","input_counts",":","Number","of","inputs","associated","with","each","output","index",".","metric_counts",":","Number","of","metrics","associated","with","each","output","index",".","size_estimator_fn",":","Function","to","use","for","estimating","the","size","of","the","inputs",".","desired_batch_size",":","FOR","TESTING","ONLY","."]
code: def __init__(
      self,
      input_counts: List[int],
      metric_counts: List[int],
      size_estimator_fn: Callable[[Any], int],
      desired_batch_size: Optional[int] = None,
  ):
      """Initializes accumulator using a list of metric counts per output.
  
      Args:
        input_counts: Number of inputs associated with each output index.
        metric_counts: Number of metrics associated with each output index.
        size_estimator_fn: Function to use for estimating the size of the inputs.
        desired_batch_size: FOR TESTING ONLY.
      """
      # Inputs have shape (num_outputs, num_metrics, num_accumulated_inputs)
      self._inputs = []
      # Weights have shape (num_outputs, num_metrics)
      self._weights = []  # type: List[List[Optional[np.ndarray]]]
      for input_count in input_counts:
          self._inputs.append(tuple([] for _ in range(input_count)))
      for output_metric_count in metric_counts:
          self._weights.append([None] * output_metric_count)
      self._size_estimator = size_estimator.SizeEstimator(
          size_threshold=self._TOTAL_INPUT_BYTE_SIZE_THRESHOLD,
          size_fn=size_estimator_fn,
      )
      if desired_batch_size and desired_batch_size > 0:
          self._desired_batch_size = desired_batch_size
      else:
          self._desired_batch_size = self._DEFAULT_DESIRED_BATCH_SIZE
  
imports: from typing import Any, Callable, List, Optional, Tuple, Union
  import numpy
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import size_estimator
label_desc: Use image node_id 1 to create a new TFMetricsAccumulator object  with example: obj = TFMetricsAccumulator(input_counts, metric_counts, size_estimator_fn, desired_batch_size)