code: def _filter_model_specs(
      eval_config: config_pb2.EvalConfig,
      eval_shared_models: Iterable[types.EvalSharedModel],
  ) -> config_pb2.EvalConfig:
      """Filters EvalConfig.model_specs to match the set of EvalSharedModels."""
      result = config_pb2.EvalConfig()
      result.CopyFrom(eval_config)
      del result.model_specs[:]
      model_names = [model.model_name for model in eval_shared_models]
      result.model_specs.extend(
          [
              spec
              for spec in eval_config.model_specs
              if spec.name in model_names
          ]
      )
      return result
  
file_path: model-analysis/tensorflow_model_analysis/extractors/counterfactual_predictions_extractor.py
imports: from typing import Dict, Iterable, Mapping, 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.extractors import extractor
  from tensorflow_model_analysis.extractors import predictions_extractor
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import model_util
label_desc: Use image node_id 3 for calling a global function with example usage: _filter_model_specs(eval_config, eval_shared_models) and returns: result