class_docstr: Custom batch converter for Pytorch.
  
  Args:
      subsampling_factor (int): The subsampling factor.
      dtype (torch.dtype): Data type to convert.
      use_source_text (bool): use source transcription.
class_docstr_tok: ["Custom","batch","converter","for","Pytorch",".","Args",":","subsampling_factor","(","int",")",":","The","subsampling","factor",".","dtype","(","torch.dtype",")",":","Data","type","to","convert",".","use_source_text","(","bool",")",":","use","source","transcription","."]
docstr: Transform a batch and send it to a device.
  
  Args:
      batch (list): The batch to transform.
      device (torch.device): The device to send to.
  
  Returns:
      tuple(torch.Tensor, torch.Tensor, torch.Tensor)
docstr_tok: ["Transform","a","batch","and","send","it","to","a","device",".","Args",":","batch","(","list",")",":","The","batch","to","transform",".","device","(","torch.device",")",":","The","device","to","send","to",".","Returns",":","tuple","(","torch.Tensor",",","torch.Tensor",",","torch.Tensor",")"]
code: def __call__(self, batch, device=torch.device("cpu")):
      """Transform a batch and send it to a device.
  
      Args:
          batch (list): The batch to transform.
          device (torch.device): The device to send to.
  
      Returns:
          tuple(torch.Tensor, torch.Tensor, torch.Tensor)
  
      """
      # batch should be located in list
      assert len(batch) == 1
      xs, ys, ys_src = batch[0]
  
      # get batch of lengths of input sequences
      ilens = np.array([x.shape[0] for x in xs])
      ilens = torch.from_numpy(ilens).to(device)
  
      xs_pad = pad_list(
          [torch.from_numpy(x).float() for x in xs], 0
      ).to(device, dtype=self.dtype)
  
      ys_pad = pad_list(
          [torch.from_numpy(np.array(y, dtype=np.int64)) for y in ys],
          self.ignore_id,
      ).to(device)
  
      if self.use_source_text:
          ys_pad_src = pad_list(
              [
                  torch.from_numpy(np.array(y, dtype=np.int64))
                  for y in ys_src
              ],
              self.ignore_id,
          ).to(device)
      else:
          ys_pad_src = None
  
      return xs_pad, ilens, ys_pad, ys_pad_src
  
imports: import itertools
  import json
  import logging
  import os
  import numpy
  import torch
  from chainer import training
  from chainer.training import extensions
  from espnet.asr.asr_utils import CompareValueTrigger, adadelta_eps_decay, adam_lr_decay, add_results_to_json, restore_snapshot, snapshot_object, torch_load, torch_resume, torch_snapshot
  from espnet.asr.pytorch_backend.asr import CustomConverter
  from espnet.asr.pytorch_backend.asr import CustomEvaluator, CustomUpdater
  from espnet.asr.pytorch_backend.asr_init import load_trained_model, load_trained_modules
  from espnet.nets.pytorch_backend.e2e_asr import pad_list
  from espnet.nets.st_interface import STInterface
  from espnet.utils.dataset import ChainerDataLoader, TransformDataset
  from espnet.utils.deterministic_utils import set_deterministic_pytorch
  from espnet.utils.dynamic_import import dynamic_import
  from espnet.utils.io_utils import LoadInputsAndTargets
  from espnet.utils.training.batchfy import make_batchset
  from espnet.utils.training.iterators import ShufflingEnabler
  from espnet.utils.training.tensorboard_logger import TensorboardLogger
  from espnet.utils.training.train_utils import check_early_stop, set_early_stop
label_desc: Use image node_id 2 for calling the CustomConverter obj's underlying member method code with example usage: obj.__call__(batch, device) and returns: xs_pad,  ilens,  ys_pad,  ys_pad_src