code: def testEvaluateWithCrossSliceLiftMetric(self):
      temp_export_dir = self._getExportDir()
      (
          _,
          export_dir,
      ) = fixed_prediction_estimator_extra_fields.simple_fixed_prediction_estimator_extra_fields(
          None, temp_export_dir
      )
      eval_config = config_pb2.EvalConfig(
          model_specs=[
              config_pb2.ModelSpec(
                  label_key="label", example_weight_key="fixed_float"
              )
          ],
          slicing_specs=[
              config_pb2.SlicingSpec(
                  feature_values={"fixed_string": "fixed_string1"}
              ),
              config_pb2.SlicingSpec(
                  feature_values={"fixed_string": "fixed_string2"}
              ),
          ],
          cross_slicing_specs=[
              config_pb2.CrossSlicingSpec(
                  baseline_spec=config_pb2.SlicingSpec(
                      feature_values={"fixed_string": "fixed_string1"}
                  ),
                  slicing_specs=[
                      config_pb2.SlicingSpec(
                          feature_values={
                              "fixed_string": "fixed_string2"
                          }
                      )
                  ],
              ),
          ],
          metrics_specs=metric_specs.specs_from_metrics(
              [lift.Lift(num_buckets=3)]
          ),
      )
      eval_shared_model = self.createTestEvalSharedModel(
          eval_saved_model_path=export_dir,
          tags=[tf.saved_model.SERVING],
      )
      extractors = [
          features_extractor.FeaturesExtractor(eval_config),
          labels_extractor.LabelsExtractor(eval_config),
          example_weights_extractor.ExampleWeightsExtractor(
              eval_config
          ),
          predictions_extractor.PredictionsExtractor(
              eval_shared_model=eval_shared_model,
              eval_config=eval_config,
          ),
          unbatch_extractor.UnbatchExtractor(),
          slice_key_extractor.SliceKeyExtractor(
              eval_config=eval_config
          ),
      ]
      evaluators = [
          metrics_plots_and_validations_evaluator.MetricsPlotsAndValidationsEvaluator(
              eval_config=eval_config,
              eval_shared_model=eval_shared_model,
          )
      ]
  
      # fixed_float used as example_weight key
      examples = [
          self._makeExample(
              prediction=0.1,
              label=0.0,
              fixed_int=1,
              fixed_float=3.0,
              fixed_string="fixed_string1",
          ),
          self._makeExample(
              prediction=0.5,
              label=0.3,
              fixed_int=1,
              fixed_float=5.0,
              fixed_string="fixed_string1",
          ),
          self._makeExample(
              prediction=0.8,
              label=0.6,
              fixed_int=2,
              fixed_float=2.0,
              fixed_string="fixed_string1",
          ),
          self._makeExample(
              prediction=0.3,
              label=0.9,
              fixed_int=1,
              fixed_float=8.0,
              fixed_string="fixed_string1",
          ),
          self._makeExample(
              prediction=0.9,
              label=1.0,
              fixed_int=1,
              fixed_float=3.0,
              fixed_string="fixed_string1",
          ),
          self._makeExample(
              prediction=0.8,
              label=0.0,
              fixed_int=2,
              fixed_float=1.0,
              fixed_string="fixed_string2",
          ),
          self._makeExample(
              prediction=0.3,
              label=0.2,
              fixed_int=1,
              fixed_float=2.0,
              fixed_string="fixed_string2",
          ),
          self._makeExample(
              prediction=0.5,
              label=0.5,
              fixed_int=1,
              fixed_float=5.0,
              fixed_string="fixed_string2",
          ),
          self._makeExample(
              prediction=0.4,
              label=0.7,
              fixed_int=2,
              fixed_float=2.0,
              fixed_string="fixed_string2",
          ),
          self._makeExample(
              prediction=0.3,
              label=1.0,
              fixed_int=2,
              fixed_float=3.0,
              fixed_string="fixed_string2",
          ),
      ]
  
      tfx_io = test_util.InMemoryTFExampleRecord(
          raw_record_column_name=constants.ARROW_INPUT_COLUMN
      )
      with beam.Pipeline() as pipeline:
          # pylint: disable=no-value-for-parameter
          metrics = (
              pipeline
              | "Create"
              >> beam.Create([e.SerializeToString() for e in examples])
              | "BatchExamples" >> tfx_io.BeamSource()
              | "InputsToExtracts"
              >> model_eval_lib.BatchedInputsToExtracts()
              | "ExtractAndEvaluate"
              >> model_eval_lib.ExtractAndEvaluate(
                  extractors=extractors, evaluators=evaluators
              )
          )
  
          # pylint: enable=no-value-for-parameter
  
          def check_metrics(got):
              try:
                  self.assertLen(got, 3)
                  example_count_key = metric_types.MetricKey(
                      name="example_count"
                  )
                  weighted_example_count_key = metric_types.MetricKey(
                      name="weighted_example_count",
                      example_weighted=True,
                  )
                  lift_key = metric_types.MetricKey(
                      name="lift@3", example_weighted=True
                  )
                  for slice_key, metrics in got:
                      if slice_key == (
                          ("fixed_string", "fixed_string1"),
                      ):
                          self.assertDictElementsAlmostEqual(
                              metrics,
                              {
                                  example_count_key: 5.0,
                                  weighted_example_count_key: 21.0,
                              },
                          )
                      elif slice_key == (
                          ("fixed_string", "fixed_string2"),
                      ):
                          self.assertDictElementsAlmostEqual(
                              metrics,
                              {
                                  weighted_example_count_key: 13.0,
                                  example_count_key: 5.0,
                              },
                          )
                      else:
                          self.assertDictElementsAlmostEqual(
                              metrics,
                              {
                                  example_count_key: 0.0,
                                  weighted_example_count_key: 8.0,
                                  lift_key: -0.211538456165,
                              },
                          )
  
              except AssertionError as err:
                  raise util.BeamAssertException(err)
  
          util.assert_that(
              metrics[constants.METRICS_KEY],
              check_metrics,
              label="metrics",
          )
  
imports: import os
  from absl.testing import parameterized
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.addons.fairness.metrics import lift
  from tensorflow_model_analysis.api import model_eval_lib
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.eval_saved_model.example_trainers import dnn_classifier
  from tensorflow_model_analysis.eval_saved_model.example_trainers import fixed_prediction_estimator_extra_fields
  from tensorflow_model_analysis.eval_saved_model.example_trainers import linear_classifier
  from tensorflow_model_analysis.eval_saved_model.example_trainers import multi_head
  from tensorflow_model_analysis.evaluators import metrics_plots_and_validations_evaluator
  from tensorflow_model_analysis.extractors import example_weights_extractor
  from tensorflow_model_analysis.extractors import features_extractor
  from tensorflow_model_analysis.extractors import labels_extractor
  from tensorflow_model_analysis.extractors import legacy_predict_extractor
  from tensorflow_model_analysis.extractors import materialized_predictions_extractor
  from tensorflow_model_analysis.extractors import predictions_extractor
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.extractors import unbatch_extractor
  from tensorflow_model_analysis.metrics import attributions
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import calibration
  from tensorflow_model_analysis.metrics import calibration_plot
  from tensorflow_model_analysis.metrics import confusion_matrix_plot
  from tensorflow_model_analysis.metrics import metric_specs
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import ndcg
  from tensorflow_model_analysis.post_export_metrics import metrics
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import validation_result_pb2
  from tfx_bsl.tfxio import raw_tf_record
  from tfx_bsl.tfxio import tensor_adapter
  from tfx_bsl.tfxio import test_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 14 for calling the MetricsPlotsAndValidationsEvaluatorTest obj's underlying member method code with example usage: obj.testEvaluateWithCrossSliceLiftMetric() without return types