class_docstr: Dataset for Causal Language modeling.
docstr: Function to send the batch to the device specified
  
  Args:
      batch: input batch
      device: device to send the data to
  Returns:
      batch with the elements on the device specified
docstr_tok: ["Function","to","send","the","batch","to","the","device","specified","Args",":","batch",":","input","batch","device",":","device","to","send","the","data","to","Returns",":","batch","with","the","elements","on","the","device","specified"]
code: def batch_to_device(
      batch: Union[Dict, List, torch.Tensor], device: str
  ) -> Union[Dict, List, torch.Tensor, str]:
      """Function to send the batch to the device specified
  
      Args:
          batch: input batch
          device: device to send the data to
      Returns:
          batch with the elements on the device specified
      """
      if isinstance(batch, torch.Tensor):
          return batch.to(device)
      elif isinstance(batch, (list, tuple)) and all(
          isinstance(item, str) for item in batch
      ):
          # Do not move list of strings to device
          return batch
      elif isinstance(batch, collections.abc.Mapping):
          return {
              key: CustomDataset.batch_to_device(value, device)
              for key, value in batch.items()
          }
      elif isinstance(batch, collections.abc.Sequence):
          return [
              CustomDataset.batch_to_device(value, device)
              for value in batch
          ]
      else:
          raise ValueError(f"Can not move {type(batch)} to device.")
  
imports: import codecs
  import collections.abc
  import logging
  from typing import Any, Dict, List, Tuple, Union
  import numpy
  import pandas
  import torch
  from torch.utils.data import Dataset
  from llm_studio.src.datasets.conversation_chain_handler import ConversationChainHandler
  from llm_studio.src.datasets.text_utils import get_tokenizer
label_desc: Use image node_id 6 for calling the CustomDataset obj's underlying member method code with example usage: obj.batch_to_device(batch, device) and returns: batch, batch, unknown, unknown