code: def from_nested_to_3d_numpy(X):
      """Convert nested Panel to 3D numpy Panel.
  
      Convert nested pandas DataFrame (with time series as pandas Series
      in cells) into NumPy ndarray with shape
      (n_instances, n_columns, n_timepoints).
  
      Parameters
      ----------
      X : pd.DataFrame
          Nested pandas DataFrame
  
      Returns
      -------
      X_3d : np.ndarrray
          3-dimensional NumPy array
      """
      # n_columns = X.shape[1]
      nested_col_mask = [*are_columns_nested(X)]
  
      # If all the columns are nested in structure
      if nested_col_mask.count(True) == len(nested_col_mask):
          X_3d = np.stack(
              df_map(X)(_convert_series_cell_to_numpy)
              .apply(lambda row: np.stack(row), axis=1)
              .to_numpy()
          )
  
      # If some columns are primitive (non-nested) then first convert to
      # multi-indexed DataFrame where the same value of these columns is
      # repeated for each timepoint
      # Then the multi-indexed DataFrame can be converted to 3d NumPy array
      else:
          X_mi = from_nested_to_multi_index(X)
          X_3d = from_multi_index_to_3d_numpy(X_mi)
  
      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 36 for calling a global function with example usage: from_nested_to_3d_numpy(X) and returns: X_3d