code: def test_1m_1_sf_sample_weights():
      """Check that sample weights are passed correctly to a single metric."""
  
      def multi_sp(y_t, y_p, p1, p2):
          """Metric to check passing of sample parameters.
  
          Verifies that p2 == y_t + y_p + p1 for all elements
          """
          assert len(y_t) == len(y_p)
          assert len(y_t) == len(p1)
          assert len(y_t) == len(p2)
          assert np.array_equal(
              p2, np.asarray(y_t) + np.asarray(y_p) + np.asarray(p1)
          )
          return sum(p2)
  
      # Generate some random input data
      rng = np.random.default_rng(seed=42)
      param1 = rng.random(len(y_t))
      # Compute the expected sum
      param2 = s_w + y_p + param1
  
      # Note that we pass in the s_w array for y_true, to get
      # a little more variety in the results
      target = metrics.MetricFrame(
          metrics=multi_sp,
          y_true=s_w,
          y_pred=y_p,
          sensitive_features=g_1,
          sample_params={"p1": param1, "p2": param2},
      )
      # Check on ci_quantiles
      assert target.ci_quantiles is None
  
      # Sanity check types
      assert isinstance(target.overall, float)
      assert isinstance(target.by_group, pd.Series)
      assert target.by_group.shape == (2,)
  
      # Check the overall value
      assert target.overall == sum(param2)
  
      # Look at the by_group values for each subgroup identified by g_1
      for g in g_1:
          mask = g_1 == g
          assert target.by_group[g] == sum(param2[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 5 for calling a global function with example usage: test_1m_1_sf_sample_weights() and returns: sum