code: def test_boostrap_sample_combine_fn_per_slice(self):
      x_key = metric_types.MetricKey("x")
      y_key = metric_types.MetricKey("y")
      cm_key = metric_types.MetricKey("confusion_matrix")
      cm_metric = binary_confusion_matrices.Matrices(
          thresholds=[0.5], tp=[0], fp=[1], tn=[2], fn=[3]
      )
      skipped_metric_key = metric_types.MetricKey("skipped_metric")
      slice_key1 = (("slice_feature", 1),)
      slice_key2 = (("slice_feature", 2),)
      samples = [
          # unsampled value for slice 1
          (
              slice_key1,
              confidence_intervals_util.SampleMetrics(
                  sample_id=poisson_bootstrap._FULL_SAMPLE_ID,
                  metrics={
                      x_key: 1.6,
                      y_key: 16,
                      cm_key: cm_metric,
                      skipped_metric_key: 100,
                  },
              ),
          ),
          # sample values 1 of 2 for slice 1
          (
              slice_key1,
              confidence_intervals_util.SampleMetrics(
                  sample_id=0,
                  metrics={
                      x_key: 1,
                      y_key: 10,
                      cm_key: cm_metric,
                      skipped_metric_key: 45,
                  },
              ),
          ),
          # sample values 2 of 2 for slice 1
          (
              slice_key1,
              confidence_intervals_util.SampleMetrics(
                  sample_id=1,
                  metrics={
                      x_key: 2,
                      y_key: 20,
                      cm_key: cm_metric,
                      skipped_metric_key: 55,
                  },
              ),
          ),
          # unsampled value for slice 2
          (
              slice_key2,
              confidence_intervals_util.SampleMetrics(
                  sample_id=poisson_bootstrap._FULL_SAMPLE_ID,
                  metrics={
                      x_key: 3.3,
                      y_key: 33,
                      cm_key: cm_metric,
                      skipped_metric_key: 1000,
                  },
              ),
          ),
          # sample values 1 of 2 for slice 2
          (
              slice_key2,
              confidence_intervals_util.SampleMetrics(
                  sample_id=0,
                  metrics={
                      x_key: 2,
                      y_key: 20,
                      cm_key: cm_metric,
                      skipped_metric_key: 450,
                  },
              ),
          ),
          # sample values 2 of 2 for slice 2
          (
              slice_key2,
              confidence_intervals_util.SampleMetrics(
                  sample_id=1,
                  metrics={
                      x_key: 4,
                      y_key: 40,
                      cm_key: cm_metric,
                      skipped_metric_key: 550,
                  },
              ),
          ),
      ]
  
      with beam.Pipeline() as pipeline:
          result = (
              pipeline
              | "Create" >> beam.Create(samples, reshuffle=False)
              | "CombineSamplesPerKey"
              >> beam.CombinePerKey(
                  poisson_bootstrap._BootstrapSampleCombineFn(
                      num_bootstrap_samples=2,
                      skip_ci_metric_keys=[skipped_metric_key],
                  )
              )
          )
  
          def check_result(got_pcoll):
              expected_pcoll = [
                  (
                      slice_key1,
                      {
                          x_key: types.ValueWithTDistribution(
                              sample_mean=1.5,
                              # sample_standard_deviation=0.5
                              sample_standard_deviation=np.std(
                                  [1, 2], ddof=1
                              ),
                              sample_degrees_of_freedom=1,
                              unsampled_value=1.6,
                          ),
                          y_key: types.ValueWithTDistribution(
                              sample_mean=15.0,
                              # sample_standard_deviation=5,
                              sample_standard_deviation=np.std(
                                  [10, 20], ddof=1
                              ),
                              sample_degrees_of_freedom=1,
                              unsampled_value=16,
                          ),
                          cm_key: types.ValueWithTDistribution(
                              sample_mean=cm_metric,
                              sample_standard_deviation=cm_metric * 0,
                              sample_degrees_of_freedom=1,
                              unsampled_value=cm_metric,
                          ),
                          skipped_metric_key: 100,
                      },
                  ),
                  (
                      slice_key2,
                      {
                          x_key: types.ValueWithTDistribution(
                              sample_mean=3.0,
                              # sample_standard_deviation=1,
                              sample_standard_deviation=np.std(
                                  [2, 4], ddof=1
                              ),
                              sample_degrees_of_freedom=1,
                              unsampled_value=3.3,
                          ),
                          y_key: types.ValueWithTDistribution(
                              sample_mean=30.0,
                              # sample_standard_deviation=10,
                              sample_standard_deviation=np.std(
                                  [20, 40], ddof=1
                              ),
                              sample_degrees_of_freedom=1,
                              unsampled_value=33,
                          ),
                          cm_key: types.ValueWithTDistribution(
                              sample_mean=cm_metric,
                              sample_standard_deviation=cm_metric * 0,
                              sample_degrees_of_freedom=1,
                              unsampled_value=cm_metric,
                          ),
                          skipped_metric_key: 1000,
                      },
                  ),
              ]
              self.assertCountEqual(expected_pcoll, got_pcoll)
  
          util.assert_that(result, check_result)
  
file_path: model-analysis/tensorflow_model_analysis/evaluators/poisson_bootstrap_test.py
imports: from absl.testing import absltest
  import apache_beam
  from apache_beam.testing import util
  import numpy
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.evaluators import confidence_intervals_util
  from tensorflow_model_analysis.evaluators import poisson_bootstrap
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import metric_types
label_desc: Use image node_id 3 for calling the PoissonBootstrapTest obj's underlying member method code with example usage: obj.test_boostrap_sample_combine_fn_per_slice() without return types