code: def test_transform_array(self):
      names = self.data.index.names
      transformed_array = self.grouping.transform_array(
          self.data.values, lambda x: x.mean(), level=0
      )
      cols = [names[0]] + list(self.data.columns)
      df = self.data.reset_index()[cols].set_index(names[0])
      grouped = df[self.data.columns].groupby(level=0)
      expected = grouped.apply(lambda x: x.mean())
      np.testing.assert_allclose(transformed_array, expected.values)
  
      if len(names) > 1:
          transformed_array = self.grouping.transform_array(
              self.data.values, lambda x: x.mean(), level=1
          )
          cols = [names[1]] + list(self.data.columns)
          df = self.data.reset_index()[cols].set_index(names[1])
          grouped = df[self.data.columns].groupby(level=0)
          expected = grouped.apply(lambda x: x.mean())[
              self.data.columns
          ]
          np.testing.assert_allclose(transformed_array, expected.values)
  
imports: from statsmodels.compat.pandas import assert_frame_equal, assert_series_equal
  import numpy
  from numpy.testing import assert_equal
  import pandas
  import pytest
  from scipy import sparse
  from statsmodels.tools.grouputils import dummy_sparse, Grouping, Group, combine_indices, group_sums
  from statsmodels.datasets import grunfeld, anes96
label_desc: Use image node_id 5 for calling the CheckGrouping obj's underlying member method code with example usage: obj.test_transform_array() without return types