code: def testAssertGeneralMetricsComputedWithBeamAre(self):
      temp_eval_export_dir = self._getEvalExportDir()
      (
          _,
          eval_export_dir,
      ) = fixed_prediction_estimator_extra_fields.simple_fixed_prediction_estimator_extra_fields(
          None, temp_eval_export_dir
      )
      examples = [
          self.makeExample(
              prediction=0.0,
              label=0.0,
              fixed_string="negative_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
          self.makeExample(
              prediction=0.2,
              label=0.0,
              fixed_string="negative_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
          self.makeExample(
              prediction=0.4,
              label=0.0,
              fixed_string="negative_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
          self.makeExample(
              prediction=0.8,
              label=1.0,
              fixed_string="positive_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
          self.makeExample(
              prediction=0.9,
              label=1.0,
              fixed_string="positive_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
          self.makeExample(
              prediction=1.0,
              label=1.0,
              fixed_string="positive_slice",
              fixed_float=0.0,
              fixed_int=0,
          ),
      ]
      expected_slice_metrics = {}
      expected_slice_metrics[()] = {
          "average_loss": (0.00 + 0.04 + 0.16 + 0.04 + 0.01 + 0.00)
          / 6.0,
          "mae": 0.15,
          # Note that we don't check the exact value because of numerical errors.
          metric_keys.AUC: tfma_unit.BoundedValue(0.98, 1.00),
      }
      # We don't check AUC for the positive / negative only slices because
      # it's not clear what the value should be.
      expected_slice_metrics[(("fixed_string", "negative_slice"),)] = {
          "average_loss": (0.00 + 0.04 + 0.16) / 3.0,
          "mae": 0.2,
      }
      expected_slice_metrics[(("fixed_string", "positive_slice"),)] = {
          "average_loss": (0.04 + 0.01 + 0.00) / 3.0,
          "mae": 0.1,
      }
  
      def add_metrics(features, predictions, labels):
          del features
          metric_ops = {
              "mae": tf.compat.v1.metrics.mean_absolute_error(
                  labels, predictions
              ),
          }
          return metric_ops
  
      with beam.Pipeline() as pipeline:
          examples_pcollection = pipeline | "Create" >> beam.Create(
              examples
          )
          self.assertGeneralMetricsComputedWithBeamAre(
              eval_saved_model_path=eval_export_dir,
              examples_pcollection=examples_pcollection,
              slice_spec=[
                  slicer.SingleSliceSpec(),
                  slicer.SingleSliceSpec(columns=["fixed_string"]),
              ],
              add_metrics_callbacks=[
                  add_metrics,
                  post_export_metrics.auc(),
              ],
              expected_slice_metrics=expected_slice_metrics,
          )
  
file_path: model-analysis/tensorflow_model_analysis/api/tfma_unit_test.py
imports: import os
  import apache_beam
  import tensorflow
  from tensorflow_model_analysis.api import tfma_unit
  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_extra_fields
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  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 5 for calling the TFMAUnitTest obj's underlying member method code with example usage: obj.testAssertGeneralMetricsComputedWithBeamAre() and returns: metric_ops