code: def _compare_nested_frame(func, x, y, **kwargs):
      """Compare two nested pd.DataFrames.
  
      Parameters
      ----------
      func : function
          Function from np.testing for comparing arrays.
      x : pd.DataFrame
      y : pd.DataFrame
      kwargs : dict
          Keyword argument for function
  
      Raises
      ------
      AssertionError
          If x and y are not equal
      """
      # We iterate over columns and rows to make cell-wise comparisons.
      # Tabularizing the data first would simplify this, but does not
      # work for unequal length data.
  
      # In rare cases, x and y may be empty (e.g. TSFreshRelevantFeatureExtractor) and
      # we cannot compare individual cells, so we simply check if everything else is
      # equal here.
      assert isinstance(x, pd.DataFrame)
      if x.empty:
          assert_frame_equal(x, y)
  
      elif is_nested_dataframe(x):
          # Check if both inputs have the same shape
          if not x.shape == y.shape:
              raise ValueError("Found inputs with different shapes")
  
          # Iterate over columns
          n_columns = x.shape[1]
          for i in range(n_columns):
              xc = x.iloc[:, i].tolist()
              yc = y.iloc[:, i].tolist()
  
              # Iterate over rows, checking if individual cells are equal
              for xci, yci in zip(xc, yc):
                  func(xci, yci, **kwargs)
  
imports: from inspect import isclass, signature
  import numpy
  import pandas
  from pandas.testing import assert_frame_equal
  from sklearn.utils.validation import check_random_state
  from sktime.alignment.base import BaseAligner
  from sktime.base import BaseEstimator, BaseObject
  from sktime.classification.base import BaseClassifier
  from sktime.classification.early_classification import BaseEarlyClassifier
  from sktime.clustering.base import BaseClusterer
  from sktime.datatypes._panel._check import is_nested_dataframe
  from sktime.dists_kernels import BasePairwiseTransformer, BasePairwiseTransformerPanel
  from sktime.forecasting.base import BaseForecaster
  from sktime.registry import scitype
  from sktime.regression.base import BaseRegressor
  from sktime.tests._config import VALID_ESTIMATOR_TYPES
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 5 for calling a global function with example usage: _compare_nested_frame(func, x, y) without return types