code: def to_numpy_dataset(
      df: DataFrame, backend: Optional["Backend"] = None
  ) -> Dict[str, np.ndarray]:  # noqa: F821
      """Returns a dictionary of numpy arrays, keyed by the columns of the given dataframe."""
      dataset = {}
      for col in df.columns:
          res = df[col]
          if backend and is_dask_backend(backend):
              res = res.compute()
          if len(df.index) != 0:
              dataset[col] = np.stack(res.to_numpy())
          else:
              # Dataframe is empty.
              # Use to_list() directly, as np.stack() requires at least one array to stack.
              dataset[col] = res.to_list()
      return dataset
  
file_path: ludwig/ludwig/utils/dataframe_utils.py
imports: from typing import Dict, List, Optional, Tuple
  import numpy
  import pandas
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import DASK_MODULE_NAME
  from ludwig.data.dataframe.base import DataFrameEngine
  from ludwig.utils.types import DataFrame
label_desc: Use image node_id 6 for calling a global function with example usage: to_numpy_dataset(df, backend) and returns: dataset