code: def classifier_extra_metrics(features, labels, predictions):
      """Returns extra metrics to use with classifier."""
      if "logistic" in predictions:
          metrics = {
              "my_mean_prediction": tf.compat.v1.metrics.mean(
                  predictions["logistic"]
              ),
              "my_mean_age": tf.compat.v1.metrics.mean(features["age"]),
          }
          if labels.dtype != tf.string:
              metrics.update(
                  {
                      "my_mean_label": tf.compat.v1.metrics.mean(
                          labels
                      ),
                      "my_mean_age_times_label": tf.compat.v1.metrics.mean(
                          labels * features["age"]
                      ),
                  }
              )
          return metrics
      # Logistic won't be present in multiclass cases.
      return {
          "mean_english_prediction": tf.compat.v1.metrics.mean(
              predictions["probabilities"][0]
          ),
          "my_mean_age": tf.compat.v1.metrics.mean(features["age"]),
      }
  
file_path: model-analysis/tensorflow_model_analysis/eval_saved_model/example_trainers/util.py
imports: import tensorflow
  from tensorflow_model_analysis.eval_saved_model import export
  from tensorflow_model_analysis.eval_saved_model import util
label_desc: Use image node_id 7 for calling a global function with example usage: classifier_extra_metrics(features, labels, predictions) and returns: dict, metrics