code: def _addPyFuncMetricCallback(  # pylint: disable=invalid-name
      features_dict, predictions_dict, labels_dict
  ):
      del features_dict
      del predictions_dict
  
      total_value = tf.compat.v1.Variable(
          initial_value=0.0,
          dtype=tf.float64,
          trainable=False,
          collections=[
              tf.compat.v1.GraphKeys.METRIC_VARIABLES,
              tf.compat.v1.GraphKeys.LOCAL_VARIABLES,
          ],
          validate_shape=True,
          name="total",
      )
  
      def my_func(x):
          return np.sum(x, dtype=np.float64)
  
      update_op = tf.compat.v1.assign_add(
          total_value,
          tf.compat.v1.py_func(my_func, [labels_dict], tf.float64),
      )
      value_op = tf.identity(total_value)
      metric_ops = {}
      metric_ops["py_func_label_sum"] = (value_op, update_op)
      return metric_ops
  
imports: import os
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis.api import model_eval_lib
  from tensorflow_model_analysis.api import tfma_unit
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.eval_saved_model.example_trainers import fixed_prediction_estimator
  from tensorflow_model_analysis.eval_saved_model.example_trainers import fixed_prediction_estimator_no_labels
  from tensorflow_model_analysis.eval_saved_model.example_trainers import linear_classifier
  from tensorflow_model_analysis.evaluators import legacy_metrics_and_plots_evaluator
  from tensorflow_model_analysis.extractors import legacy_predict_extractor
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.post_export_metrics import metrics
  from tensorflow_model_analysis.post_export_metrics import post_export_metrics
  from tensorflow_model_analysis.slicer import slicer_lib
label_desc: Use image node_id 2 for calling a global function with example usage: _addPyFuncMetricCallback(features_dict, predictions_dict, labels_dict) and returns: metric_ops, np