code: def example_count(
      name: str = EXAMPLE_COUNT_NAME,
      model_names: Optional[List[str]] = None,
      output_names: Optional[List[str]] = None,
      sub_keys: Optional[List[metric_types.SubKey]] = None,
      example_weighted: bool = False,
  ) -> metric_types.MetricComputations:
      """Returns metric computations for example count."""
      computations = []
      for model_name in model_names or [""]:
          for output_name in output_names or [""]:
              keys = []
              for sub_key in sub_keys or [None]:
                  key = metric_types.MetricKey(
                      name=name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                  )
                  keys.append(key)
  
              # Note: This cannot be implemented based on the weight stored in
              # calibration because weighted example count is used with multi-class, etc
              # models that do not use calibration metrics.
              # The combiner only needs example weights in case users do not have
              # predictions or labels.
              computations.append(
                  metric_types.MetricComputation(
                      keys=keys,
                      preprocessors=[
                          metric_types.StandardMetricInputsPreprocessor(
                              include_filter={
                                  constants.EXAMPLE_WEIGHTS_KEY: {}
                              },
                              include_default_inputs=False,
                          )
                      ],
                      combiner=_ExampleCountCombiner(
                          model_name,
                          output_name,
                          keys,
                          example_weighted,
                      ),
                  )
              )
      return computations
  
file_path: model-analysis/tensorflow_model_analysis/metrics/example_count.py
imports: from typing import Optional, Dict, Iterable, List
  import apache_beam
  import numpy
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.utils import util
label_desc: Use image node_id 1 for calling a global function with example usage: example_count(name, model_names, output_names, sub_keys, example_weighted) and returns: computations