code: def _create_train_and_eval_spec(trainer_fn_args, schema):
      """Build the estimator using the high level API.
  
      Args:
        trainer_fn_args: Holds args used to train the model as name/value pairs.
        schema: Holds the schema of the training examples.
  
      Returns:
        A dict of the following:
          - estimator: The estimator that will be used for training and eval.
          - train_spec: Spec for training.
          - eval_spec: Spec for eval.
          - eval_input_receiver_fn: Input function for eval.
      """
  
      tf_transform_output = tft.TFTransformOutput(
          trainer_fn_args.transform_output
      )
  
      train_input_fn = (
          lambda: _input_fn(  # pylint: disable=g-long-lambda
              trainer_fn_args.train_files,
              trainer_fn_args.data_accessor,
              tf_transform_output,
              batch_size=constants.TRAIN_BATCH_SIZE,
          )
      )
  
      eval_input_fn = (
          lambda: _input_fn(  # pylint: disable=g-long-lambda
              trainer_fn_args.eval_files,
              trainer_fn_args.data_accessor,
              tf_transform_output,
              batch_size=constants.EVAL_BATCH_SIZE,
          )
      )
  
      train_spec = (
          tf_estimator.TrainSpec(  # pylint: disable=g-long-lambda
              train_input_fn, max_steps=trainer_fn_args.train_steps
          )
      )
  
      serving_receiver_fn = lambda: _example_serving_receiver_fn(  # pylint: disable=g-long-lambda
          tf_transform_output, schema
      )
  
      exporter = tf_estimator.FinalExporter(
          "chicago-taxi", serving_receiver_fn
      )
      eval_spec = tf_estimator.EvalSpec(
          eval_input_fn,
          steps=trainer_fn_args.eval_steps,
          exporters=[exporter],
          name="chicago-taxi-eval",
      )
  
      run_config = tf_estimator.RunConfig(
          save_checkpoints_steps=999, keep_checkpoint_max=1
      )
  
      run_config = run_config.replace(
          model_dir=trainer_fn_args.serving_model_dir
      )
  
      estimator = _build_estimator(
          hidden_units=constants.HIDDEN_UNITS, config=run_config
      )
  
      # Create an input receiver for TFMA processing
      receiver_fn = lambda: _eval_input_receiver_fn(  # pylint: disable=g-long-lambda
          tf_transform_output, schema
      )
  
      return {
          "estimator": estimator,
          "train_spec": train_spec,
          "eval_spec": eval_spec,
          "eval_input_receiver_fn": receiver_fn,
      }
  
file_path: tfx/tfx/experimental/templates/taxi/models/estimator_model/model.py
imports: from absl import logging
  import tensorflow
  from tensorflow import estimator
  import tensorflow_model_analysis
  import tensorflow_transform
  from tensorflow_transform.tf_metadata import schema_utils
  from tfx import v1
  from tfx.experimental.templates.taxi.models import features
  from tfx.experimental.templates.taxi.models.estimator_model import constants
  from tfx_bsl.public import tfxio
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 7 for calling a global function with example usage: _create_train_and_eval_spec(trainer_fn_args, schema) and returns: dict