code: def test_multid_input_output():
      # In this, both y_t and y_p are 2d arrays
      # The metric results are also arrays
      metric_fn = functools.partial(
          skm.r2_score, multioutput="raw_values"
      )
      metric_fn.__name__ = "multid_metric"
  
      y_t_2 = np.random.rand(len(g_1), 2)
      y_p_2 = np.random.rand(len(g_1), 2)
  
      target = metrics.MetricFrame(
          metrics=metric_fn,
          y_true=y_t_2,
          y_pred=y_p_2,
          sensitive_features=g_1,
      )
  
      expected_overall = skm.r2_score(
          y_t_2, y_p_2, multioutput="raw_values"
      )
      # Have to use allclose rather than equal since we don't know how
      # groupby will do its slicing
      assert np.allclose(
          target.overall, expected_overall, rtol=1e-12, atol=1e-10
      )
      for g in np.unique(g_1):
          mask = g_1 == g
  
          expected = skm.r2_score(
              y_t_2[mask], y_p_2[mask], multioutput="raw_values"
          )
          actual = target.by_group[g]
          assert np.allclose(actual, expected, rtol=1e-12, atol=1e-10)
  
file_path: fairlearn/test/unit/metrics/test_metricframe_nonscalar.py
imports: import functools
  import numpy
  import sklearn.metrics
  import fairlearn.metrics
  from .data_for_test import g_1, g_2, y_p, y_t
label_desc: Use image node_id 4 for calling a global function with example usage: test_multid_input_output() without return types