code: def from_multi_index_to_3d_numpy(X):
      """Convert pandas multi-index Panel to numpy 3D Panel.
  
      Convert panel data stored as pandas multi-index DataFrame to
      Numpy 3-dimensional NumPy array (n_instances, n_columns, n_timepoints).
  
      Parameters
      ----------
      X : pd.DataFrame
          The multi-index pandas DataFrame
  
      Returns
      -------
      X_3d : np.ndarray
          3-dimensional NumPy array (n_instances, n_columns, n_timepoints)
      """
      if X.index.nlevels != 2:
          raise ValueError(
              "Multi-index DataFrame should have 2 levels."
          )
  
      n_instances = len(X.index.get_level_values(0).unique())
      n_timepoints = len(X.index.get_level_values(1).unique())
      n_columns = X.shape[1]
  
      X_coerced = _coerce_df_dtypes(X)
      X_values = X_coerced.values
      X_3d = X_values.reshape(
          n_instances, n_timepoints, n_columns
      ).swapaxes(1, 2)
  
      return X_3d
  
imports: import numpy
  import pandas
  from sktime.datatypes._convert_utils._coerce import _coerce_df_dtypes
  from sktime.datatypes._convert_utils._convert import _extend_conversions
  from sktime.datatypes._panel._registry import MTYPE_LIST_PANEL
  from sktime.utils.pandas import df_map
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 27 for calling a global function with example usage: from_multi_index_to_3d_numpy(X) and returns: X_3d