code: def simple_fixed_prediction_estimator_no_labels(
      export_path,
      eval_export_path,
      output_prediction_key=prediction_keys.PredictionKeys.PREDICTIONS,
  ):
      """Exports a simple fixed prediction estimator with no labels."""
  
      def model_fn(features, mode, config):
          """Model function for custom estimator."""
          del config
          predictions = features["prediction"]
  
          if output_prediction_key is not None:
              predictions_dict = {
                  output_prediction_key: predictions,
              }
          else:
              # For simulating Estimators which don't return a predictions dict in
              # EVAL mode.
              predictions_dict = {}
  
          if mode == tf_estimator.ModeKeys.PREDICT:
              return tf_estimator.EstimatorSpec(
                  mode=mode,
                  predictions=predictions_dict,
                  export_outputs={
                      tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY: tf_estimator.export.RegressionOutput(
                          predictions
                      )
                  },
              )
  
          # We use create a nonsensical loss that is easy to compute:
          # loss = mean(predictions^2) and export it as as the average loss for
          # testing that the metrics are computed correctly.
          loss = tf.compat.v1.losses.mean_squared_error(
              predictions, tf.zeros_like(predictions)
          )
          train_op = tf.compat.v1.assign_add(
              tf.compat.v1.train.get_global_step(), 1
          )
          eval_metric_ops = {
              metric_keys.MetricKeys.LOSS_MEAN: tf.compat.v1.metrics.mean(
                  loss
              ),
          }
  
          return tf_estimator.EstimatorSpec(
              mode=mode,
              loss=loss,
              train_op=train_op,
              predictions=predictions_dict,
              eval_metric_ops=eval_metric_ops,
          )
  
      def train_input_fn():
          """Train input function."""
          return {
              "prediction": tf.constant([[1.0], [2.0], [3.0], [4.0]]),
          }
  
      estimator = tf_estimator.Estimator(model_fn=model_fn)
      estimator.train(input_fn=train_input_fn, steps=1)
  
      feature_spec = {
          "prediction": tf.io.FixedLenFeature([1], dtype=tf.float32)
      }
      eval_feature_spec = {
          "prediction": tf.io.FixedLenFeature([1], dtype=tf.float32),
      }
  
      return util.export_model_and_eval_model(
          estimator=estimator,
          serving_input_receiver_fn=(
              tf_estimator.export.build_parsing_serving_input_receiver_fn(
                  feature_spec
              )
          ),
          eval_input_receiver_fn=export.build_parsing_eval_input_receiver_fn(
              eval_feature_spec, label_key=None
          ),
          export_path=export_path,
          eval_export_path=eval_export_path,
      )
  
imports: import tensorflow
  from tensorflow import estimator
  from tensorflow_model_analysis.eval_saved_model import export
  from tensorflow_model_analysis.eval_saved_model.example_trainers import util
  from tensorflow.python.estimator.canned import metric_keys
  from tensorflow.python.estimator.canned import prediction_keys
label_desc: Use image node_id 1 for calling a global function with example usage: simple_fixed_prediction_estimator_no_labels(export_path, eval_export_path, output_prediction_key) and returns: util, tf_estimator, dict, tf_estimator