code: def _trials_dataframe(
      study: "optuna.Study", attrs: tuple[str, ...], multi_index: bool
  ) -> "pd.DataFrame":
      _imports.check()
  
      # If no trials, return an empty dataframe.
      if len(study.get_trials(deepcopy=False)) == 0:
          return pd.DataFrame()
  
      if "value" in attrs and study._is_multi_objective():
          attrs = tuple(
              "values" if attr == "value" else attr for attr in attrs
          )
  
      records, columns = _create_records_and_aggregate_column(
          study, attrs
      )
  
      df = pd.DataFrame(
          records, columns=pd.MultiIndex.from_tuples(columns)
      )
  
      if not multi_index:
          df.columns = _flatten_columns(columns)
  
      return df
  
file_path: optuna/optuna/study/_dataframe.py
imports: from __future__ import annotations
  import collections
  from typing import Any
  from typing import DefaultDict
  from typing import Set
  import optuna
  from optuna._imports import try_import
  from optuna.trial._state import TrialState
label_desc: Use image node_id 3 for calling a global function with example usage: _trials_dataframe(study, attrs, multi_index) and returns: df, pd