class_docstr: Adapter that handles `torch.utils.data.DataLoader`.
class_docstr_tok: ["Adapter","that","handles","`","torch.utils.data.DataLoader","`","."]
code: def peek_and_get_tensor_spec(self):
      from keras.utils.module_utils import tensorflow as tf
  
      batch_data = next(iter(self._dataloader))
  
      def get_tensor_spec(x):
          shape = x.shape
          if len(shape) < 1:
              raise ValueError(
                  "When passing a Pytorch DataLoader to a Keras model, "
                  "the arrays returned by the generator "
                  "must be at least rank 1. Received: "
                  f"{x} of rank {len(x.shape)}"
              )
          shape = list(shape)
          shape[
              0
          ] = None  # The batch size is not guaranteed to be static.
  
          # No easy way to get string representation of dtype in torch
          # TODO: Figure out a better way to achieve this
          dtype = str(x.dtype).replace("torch.", "")
          return tf.TensorSpec(shape=shape, dtype=dtype)
  
      return tuple(tree.map_structure(get_tensor_spec, batch_data))
  
file_path: keras/keras/trainers/data_adapters/torch_data_loader_adapter.py
imports: import numpy
  import tree
  from keras.trainers.data_adapters.data_adapter import DataAdapter
label_desc: Use image node_id 5 for calling the TorchDataLoaderAdapter obj's underlying member method code with example usage: obj.peek_and_get_tensor_spec() and returns: tuple, tf