code: def test_2m_1sf_sample_weights():
      """Check that sample weights are passed correctly to two metrics."""
  
      def sp_is_sum(y_t, y_p, some_param_name):
          """Metric accepting a single sample parameter.
  
          Checks that the sample parameter stores the sum of
          y_t and y_p for all elements
          """
          assert len(y_t) == len(y_p)
          assert len(y_t) == len(some_param_name)
          assert np.array_equal(some_param_name, y_t + y_p)
          assert isinstance(some_param_name, np.ndarray)
          return sum(some_param_name)
  
      def multi_sp(y_t, y_p, some_param_name, some_other):
          """Metric accepting multiple sample parameters.
  
          Checks that
          some_other == y_t + y_p * some_param_name
          for all elements
          """
          assert len(y_t) == len(y_p)
          assert len(y_t) == len(some_param_name)
          assert len(y_t) == len(some_other)
          assert np.array_equal(some_other, y_t + y_p * some_param_name)
          assert isinstance(some_other, np.ndarray)
          return sum(some_other)
  
      # Give the metrics some unusual names
      m1 = r"! # \ | $"
      m2 = r"& % ^"
      metrics_dict = {m1: sp_is_sum, m2: multi_sp}
  
      # Generate some random inputs for multi_sp
      rng = np.random.default_rng(seed=6 * 9)
      param1 = rng.integers(low=0, high=100, size=len(y_t))
  
      # Generate the columns of expected values for the two metrics
      sums = y_t + s_w
      multis = y_t + s_w * param1
  
      # Set up the sample parameter dictionary
      # Note that although the metric functions have one parameter
      # with the same name, each one gets a different input array
      sample_params = {
          m1: {"some_param_name": sums},
          m2: {"some_param_name": param1, "some_other": multis},
      }
  
      # Compute the metrics. Note that we pass in the
      # s_w array for y_pred, in the interests of having some
      # more variety in the results
      target = metrics.MetricFrame(
          metrics=metrics_dict,
          y_true=y_t,
          y_pred=s_w,
          sensitive_features=g_2,
          sample_params=sample_params,
      )
      # Check on ci_quantiles
      assert target.ci_quantiles is None
  
      # Check we have correct return types
      assert isinstance(target.overall, pd.Series)
      assert isinstance(target.by_group, pd.DataFrame)
  
      # Check we have expected number of elements
      assert len(target.overall) == 2
      assert target.by_group.shape == (2, 2)
  
      # Check overall values
      assert target.overall[m1] == sum(sums)
      assert target.overall[m2] == sum(multis)
  
      # Check by group values for each subgroup identified by g_2
      for group in g_2:
          mask = g_2 == group
          assert target.by_group[m1][group] == sum(sums[mask])
          assert target.by_group[m2][group] == sum(multis[mask])
  
file_path: fairlearn/test/unit/metrics/test_metricframe_smoke.py
imports: from test.unit.input_convertors import conversions_for_1d
  import numpy
  import pandas
  import pytest
  import sklearn.metrics
  import fairlearn.metrics
  from .data_for_test import g_1, g_2, g_3, g_4, s_w, y_p, y_t
label_desc: Use image node_id 6 for calling a global function with example usage: test_2m_1sf_sample_weights() and returns: sum, sum