code: def _LegacyEvalInputReceiver(  # pylint: disable=invalid-name
      features: types.TensorTypeMaybeDict,
      labels: Optional[types.TensorTypeMaybeDict],
      receiver_tensors: Dict[str, types.TensorType],
      input_refs: Optional[types.TensorType] = None,
  ) -> EvalInputReceiverType:
      """Returns a legacy eval_input_receiver_fn.
  
      This is for testing purposes only.
  
      Args:
        features: A `Tensor`, `SparseTensor`, or dict of string to `Tensor` or
          `SparseTensor`, specifying the features to be passed to the model.
        labels: A `Tensor`, `SparseTensor`, or dict of string to `Tensor` or
          `SparseTensor`, specifying the labels to be passed to the model. If your
          model is an unsupervised model whose `model_fn` does not accept a `labels`
          argument, you may pass None instead.
        receiver_tensors: A dict of string to `Tensor` containing exactly key named
          'examples', which maps to the single input node that the receiver expects
          to be fed by default. Typically this is a placeholder expecting serialized
          `tf.Example` protos.
        input_refs: Optional. A 1-D integer `Tensor` that is batch-aligned with
          `features` and `labels` which is an index into
          receiver_tensors['examples'] indicating where this slice of features /
          labels came from. If not provided, defaults to range(0,
          len(receiver_tensors['examples'])).
  
      Raises:
        ValueError: receiver_tensors did not contain exactly one key named
          "examples".
      """
      # Force list representation for Python 3 compatibility.
      if list(receiver_tensors) != ["examples"]:
          raise ValueError(
              "receiver_tensors must contain exactly one key named "
              "examples."
          )
  
      # Workaround for TensorFlow issue #17568. Note that we pass the
      # identity-wrapped features and labels to model_fn, but we have to feed
      # the non-identity wrapped Tensors during evaluation.
      #
      # Also note that we can't wrap predictions, so metrics that have control
      # dependencies on predictions will cause the predictions to be recomputed
      # during their evaluation.
      wrapped_features = (
          util.wrap_tensor_or_dict_of_tensors_in_identity(features)
      )
      if labels is not None:
          wrapped_labels = (
              util.wrap_tensor_or_dict_of_tensors_in_identity(labels)
          )
          receiver = export_lib.SupervisedInputReceiver(
              features=wrapped_features,
              labels=wrapped_labels,
              receiver_tensors=receiver_tensors,
          )
      else:
          receiver = export_lib.UnsupervisedInputReceiver(
              features=wrapped_features,
              receiver_tensors=receiver_tensors,
          )
  
      if input_refs is None:
          input_refs = tf.range(
              tf.size(input=receiver_tensors["examples"])
          )
      # Note that in the collection we store the unwrapped versions, because
      # we want to feed the unwrapped versions.
      _add_tfma_collections(features, labels, input_refs)
      util.add_build_data_collection()
      return receiver
  
file_path: model-analysis/tensorflow_model_analysis/eval_saved_model/export.py
imports: from typing import Any, Callable, Dict, Optional, Union
  import tensorflow
  from tensorflow import estimator
  from tensorflow_model_analysis import version
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.eval_saved_model import constants
  from tensorflow_model_analysis.eval_saved_model import encoding
  from tensorflow_model_analysis.eval_saved_model import util
  from tensorflow_model_analysis.utils import util
  from tensorflow.python.estimator.export import export
label_desc: Use image node_id 2 for calling a global function with example usage: _LegacyEvalInputReceiver(features, labels, receiver_tensors, input_refs) and returns: receiver