code: def from_3d_numpy_to_multi_index(
      X, instance_index=None, time_index=None, column_names=None
  ):
      """Convert 3D numpy Panel to pandas multi-index Panel.
  
      Convert 3-dimensional NumPy array (n_instances, n_columns, n_timepoints)
      to panel data stored as pandas multi-indexed DataFrame.
  
      Parameters
      ----------
      X : np.ndarray
          3-dimensional NumPy array (n_instances, n_columns, n_timepoints)
  
      instance_index : str
          Name of the multi-index level corresponding to the DataFrame's instances
  
      time_index : str
          Name of multi-index level corresponding to DataFrame's timepoints
  
  
      Returns
      -------
      X_mi : pd.DataFrame
          The multi-indexed pandas DataFrame
      """
      if X.ndim != 3:
          msg = " ".join(
              [
                  "Input should be 3-dimensional NumPy array with shape",
                  "(n_instances, n_columns, n_timepoints).",
              ]
          )
          raise TypeError(msg)
  
      n_instances, n_columns, n_timepoints = X.shape
      multi_index = pd.MultiIndex.from_product(
          [range(n_instances), range(n_columns), range(n_timepoints)],
          names=["instances", "columns", "timepoints"],
      )
  
      X_mi = pd.DataFrame({"X": X.flatten()}, index=multi_index)
      X_mi = X_mi.unstack(level="columns")
  
      # Assign column names
      if column_names is None:
          X_mi.columns = _make_column_names(n_columns)
  
      else:
          X_mi.columns = column_names
  
      index_rename_dict = {}
      if instance_index is not None:
          index_rename_dict["instances"] = instance_index
  
      if time_index is not None:
          index_rename_dict["timepoints"] = time_index
  
      if len(index_rename_dict) > 0:
          X_mi = X_mi.rename_axis(index=index_rename_dict)
  
      return X_mi
  
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 29 for calling a global function with example usage: from_3d_numpy_to_multi_index(X, instance_index, time_index, column_names) and returns: X_mi