code: def as_dataframe(
      ds: tf.data.Dataset,
      ds_info: Optional[dataset_info.DatasetInfo] = None,
  ) -> pd.DataFrame:
      """Convert the dataset into a pandas dataframe.
  
      Warning: The dataframe will be loaded entirely in memory, you may
      want to call `tfds.as_dataframe` on a subset of the data instead:
  
      ```
      df = tfds.as_dataframe(ds.take(10), ds_info)
      ```
  
      Args:
        ds: `tf.data.Dataset`. The tf.data.Dataset object to convert to panda
          dataframe. Examples should not be batched. The full dataset will be
          loaded.
        ds_info: Dataset info object. If given, helps improving the formatting.
          Available either through `tfds.load('mnist', with_info=True)` or
          `tfds.builder('mnist').info`
  
      Returns:
        dataframe: The `pandas.DataFrame` object
      """
      # Raise a clean error message if panda isn't installed.
      lazy_imports_lib.lazy_imports.pandas  # pylint: disable=pointless-statement
  
      class StyledDataFrame(pd.DataFrame):
          """`pandas.DataFrame` displayed as `pandas.io.formats.style.Styler`.
  
          `StyledDataFrame` is a `pandas.DataFrame` with better Jupyter notebook
          representation. Contrary to regular `pandas.DataFrame`, the `style` is
          attached to the `pandas.DataFrame`.
  
          ```
          df = StyledDataFrame(...)
          df.current_style.apply(...)  # Configure the style
          df  # The data-frame is displayed using ` pandas.io.formats.style.Styler`
          ```
          """
  
          # StyledDataFrame could be improved such as the style is forwarded when
          # selecting sub-data frames.
  
          def __init__(self, *args, **kwargs):
              super().__init__(
                  *args, **kwargs
              )  # pytype: disable=wrong-arg-count  # re-none
              # Use name-mangling for forward-compatibility in case pandas
              # adds a `_styler` attribute in the future.
              self.__styler: Optional[Styler] = None
  
          @property
          def current_style(self) -> Styler:
              """Like `pandas.DataFrame.style`, but attach the style to the DataFrame."""
              if self.__styler is None:
                  self.__styler = (
                      super().style
                  )  # pytype: disable=attribute-error  # re-none
              return self.__styler
  
          def _repr_html_(self) -> Union[None, str]:
              # See base class for doc
              if self.__styler is None:
                  return (
                      super()._repr_html_()
                  )  # pytype: disable=attribute-error  # re-none
              return (
                  self.__styler._repr_html_()
              )  # pylint: disable=protected-access
  
      # Pack `as_supervised=True` datasets
      if ds_info:
          ds = dataset_info.pack_as_supervised_ds(ds, ds_info)
  
      # Flatten the keys names, specs,... while keeping the feature key definition
      # order
      columns = _make_columns(ds.element_spec, ds_info=ds_info)
      rows = [
          _make_row_dict(ex, columns)
          for ex in dataset_utils.as_numpy(ds)
      ]
      df = StyledDataFrame(rows)
      df.current_style.format(
          {c.name: c.format_fn for c in columns if c.format_fn}
      )
      return df
  
file_path: datasets/tensorflow_datasets/core/as_dataframe.py
imports: from __future__ import annotations
  import dataclasses
  import typing
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import dataset_utils
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import pandas
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: as_dataframe(ds, ds_info) and returns: df, self, self, super