code: def flatten_df(
      df: DataFrame, df_engine: DataFrameEngine
  ) -> Tuple[DataFrame, Dict[str, Tuple]]:  # noqa: F821
      """Returns a flattened dataframe with a dictionary of the original shapes, keyed by dataframe columns."""
      # Workaround for: https://issues.apache.org/jira/browse/ARROW-5645
      column_shapes = {}
      for c in df.columns:
          df = df_engine.persist(df)
          shape = df_engine.compute(
              df_engine.map_objects(
                  df[c],
                  lambda x: np.array(x).shape,
              ).max()
          )
  
          if len(shape) > 1:
              column_shapes[c] = shape
              df[c] = df_engine.map_objects(
                  df[c], lambda x: np.array(x).reshape(-1)
              )
      return df, column_shapes
  
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 4 for calling a global function with example usage: flatten_df(df, df_engine) and returns: df,  column_shapes