code: def tensor_extension_casting(enforced: bool):
      """This context manager is used to enforce or disable tensor extension casting.
  
      Ray Datasets will automatically cast tensor columns to the ray Tensor dtype extension at the end of
      map_batches calls and before writing to Parquet. This context manager can be used to disable this behavior
      and keep the tensor columns as object dtype. This is useful for writing to Parquet using dask.
  
      Args:
          enforced (bool): Whether to enforce tensor extension casting.
      """
      from ray.data.context import DatasetContext
  
      ctx = DatasetContext.get_current()
      prev_enable_tensor_extension_casting = (
          ctx.enable_tensor_extension_casting
      )
      try:
          ctx.enable_tensor_extension_casting = enforced
          yield
      finally:
          ctx.enable_tensor_extension_casting = (
              prev_enable_tensor_extension_casting
          )
  
imports: import collections
  import logging
  from contextlib import contextmanager
  from typing import Dict
  import dask
  import dask.array
  import dask.dataframe
  import ray
  from dask.diagnostics import ProgressBar
  from packaging import version
  from pyarrow.fs import FSSpecHandler, PyFileSystem
  from ray.data import Dataset, read_parquet
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.data.dataframe.base import DataFrameEngine
  from ludwig.utils.data_utils import get_pa_schema, get_parquet_filename, split_by_slices
  from ludwig.utils.dataframe_utils import set_index_name
  from ludwig.utils.fs_utils import get_fs_and_path
label_desc: Use image node_id 3 for calling a global function with example usage: tensor_extension_casting(enforced) without return types