code: def _example_weighted_default(
      eval_config: config_pb2.EvalConfig, spec: config_pb2.MetricsSpec
  ) -> bool:
      """Returns tue if example weighted is the default for the given spec.
  
      If any of the models and/or outputs have example weights then example weighted
      will be true by default.
  
      Args:
        eval_config: Eval config.
        spec: Metrics spec to get default for.
      """
  
      # Default to using example example weights if an example weight key is set.
      def has_example_weight_key(
          model_spec: config_pb2.ModelSpec,
      ) -> bool:
          if model_spec.example_weight_key:
              return True
          if spec.output_names and model_spec.example_weight_keys:
              for output_name in spec.output_names:
                  if output_name in model_spec.example_weight_keys:
                      return True
          return False
  
      if spec.model_names:
          for model_name in spec.model_names:
              model_spec = model_util.get_model_spec(
                  eval_config, model_name
              )
              if model_spec and has_example_weight_key(model_spec):
                  return True
      else:
          for model_spec in eval_config.model_specs:
              if has_example_weight_key(model_spec):
                  return True
      return False
  
imports: import collections
  import importlib
  import json
  import re
  from typing import Any, Dict, FrozenSet, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Type, Union
  import tensorflow
  from tensorflow_model_analysis.metrics import aggregation
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import calibration
  from tensorflow_model_analysis.metrics import calibration_plot
  from tensorflow_model_analysis.metrics import confusion_matrix_metrics
  from tensorflow_model_analysis.metrics import confusion_matrix_plot
  from tensorflow_model_analysis.metrics import example_count
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import multi_class_confusion_matrix_plot
  from tensorflow_model_analysis.metrics import tf_metric_wrapper
  from tensorflow_model_analysis.metrics import weighted_example_count
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.utils import model_util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _example_weighted_default(eval_config, spec) and returns: False, False, True, True, True, True