code: def get_data_adapter(
      x,
      y=None,
      sample_weight=None,
      batch_size=None,
      steps_per_epoch=None,
      shuffle=False,
      class_weight=None,
  ):
      # Check for multi-process/worker distribution. Since only tf.dataset
      # is supported at the moment, we will raise error if the inputs fail
      # the type check
      distribution = distribution_lib.distribution()
      if getattr(
          distribution, "_is_multi_process", False
      ) and not is_tf_dataset(x):
          raise ValueError(
              "When using multi-worker distribution, the data must be provided "
              f"as a `tf.data.Dataset` instance. Received: type(x)={type(x)}."
          )
  
      if array_data_adapter.can_convert_arrays((x, y, sample_weight)):
          return ArrayDataAdapter(
              x,
              y,
              sample_weight=sample_weight,
              class_weight=class_weight,
              shuffle=shuffle,
              batch_size=batch_size,
              steps=steps_per_epoch,
          )
      elif is_tf_dataset(x):
          # Unsupported args: y, sample_weight, shuffle
          if y is not None:
              raise_unsupported_arg(
                  "y", "the targets", "tf.data.Dataset"
              )
          if sample_weight is not None:
              raise_unsupported_arg(
                  "sample_weights",
                  "the sample weights",
                  "tf.data.Dataset",
              )
          return TFDatasetAdapter(
              x, class_weight=class_weight, distribution=distribution
          )
          # TODO: should we warn or not?
          # warnings.warn(
          #     "`shuffle=True` was passed, but will be ignored since the "
          #     "data `x` was provided as a tf.data.Dataset. The Dataset is "
          #     "expected to already be shuffled "
          #     "(via `.shuffle(tf.data.AUTOTUNE)`)"
          # )
      elif isinstance(x, py_dataset_adapter.PyDataset):
          if y is not None:
              raise_unsupported_arg("y", "the targets", "PyDataset")
          if sample_weight is not None:
              raise_unsupported_arg(
                  "sample_weights", "the sample weights", "PyDataset"
              )
          return PyDatasetAdapter(
              x, class_weight=class_weight, shuffle=shuffle
          )
      elif is_torch_dataloader(x):
          if y is not None:
              raise_unsupported_arg(
                  "y", "the targets", "torch DataLoader"
              )
          if sample_weight is not None:
              raise_unsupported_arg(
                  "sample_weights",
                  "the sample weights",
                  "torch DataLoader",
              )
          if class_weight is not None:
              raise ValueError(
                  "Argument `class_weight` is not supported for torch "
                  f"DataLoader inputs. Received: class_weight={class_weight}"
              )
          return TorchDataLoaderAdapter(x)
          # TODO: should we warn or not?
          # warnings.warn(
          #     "`shuffle=True` was passed, but will be ignored since the "
          #     "data `x` was provided as a torch DataLoader. The DataLoader "
          #     "is expected to already be shuffled."
          # )
      elif isinstance(x, types.GeneratorType):
          if y is not None:
              raise_unsupported_arg("y", "the targets", "PyDataset")
          if sample_weight is not None:
              raise_unsupported_arg(
                  "sample_weights", "the sample weights", "PyDataset"
              )
          if class_weight is not None:
              raise ValueError(
                  "Argument `class_weight` is not supported for Python "
                  f"generator inputs. Received: class_weight={class_weight}"
              )
          return GeneratorDataAdapter(x)
          # TODO: should we warn or not?
          # warnings.warn(
          #     "`shuffle=True` was passed, but will be ignored since the "
          #     "data `x` was provided as a generator. The generator "
          #     "is expected to yield already-shuffled data."
          # )
      else:
          raise ValueError(
              f"Unrecognized data type: x={x} (of type {type(x)})"
          )
  
file_path: keras/keras/trainers/data_adapters/__init__.py
imports: import types
  from keras.distribution import distribution_lib
  from keras.trainers.data_adapters import array_data_adapter
  from keras.trainers.data_adapters import py_dataset_adapter
  from keras.trainers.data_adapters.array_data_adapter import ArrayDataAdapter
  from keras.trainers.data_adapters.generator_data_adapter import GeneratorDataAdapter
  from keras.trainers.data_adapters.py_dataset_adapter import PyDatasetAdapter
  from keras.trainers.data_adapters.tf_dataset_adapter import TFDatasetAdapter
  from keras.trainers.data_adapters.torch_data_loader_adapter import TorchDataLoaderAdapter
label_desc: Use image node_id 1 for calling a global function with example usage: get_data_adapter(x, y, sample_weight, batch_size, steps_per_epoch, shuffle, class_weight) and returns: ArrayDataAdapter, TFDatasetAdapter, PyDatasetAdapter, TorchDataLoaderAdapter, GeneratorDataAdapter