class_docstr: Custom batch converter for Pytorch.
  
  Args:
      subsampling_factor (int): The subsampling factor.
      dtype (torch.dtype): Data type to convert.
class_docstr_tok: ["Custom","batch","converter","for","Pytorch",".","Args",":","subsampling_factor","(","int",")",":","The","subsampling","factor",".","dtype","(","torch.dtype",")",":","Data","type","to","convert","."]
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 = batch[0]
  
      # perform subsampling
      if self.subsampling_factor > 1:
          xs = [x[:: self.subsampling_factor, :] for x in xs]
  
      # get batch of lengths of input sequences
      ilens = np.array([x.shape[0] for x in xs])
  
      # perform padding and convert to tensor
      # currently only support real number
      if xs[0].dtype.kind == "c":
          xs_pad_real = pad_list(
              [torch.from_numpy(x.real).float() for x in xs], 0
          ).to(device, dtype=self.dtype)
          xs_pad_imag = pad_list(
              [torch.from_numpy(x.imag).float() for x in xs], 0
          ).to(device, dtype=self.dtype)
          # Note(kamo):
          # {'real': ..., 'imag': ...} will be changed to ComplexTensor in E2E.
          # Don't create ComplexTensor and give it E2E here
          # because torch.nn.DataParellel can't handle it.
          xs_pad = {"real": xs_pad_real, "imag": xs_pad_imag}
      else:
          xs_pad = pad_list(
              [torch.from_numpy(x).float() for x in xs], 0
          ).to(device, dtype=self.dtype)
  
      ilens = torch.from_numpy(ilens).to(device)
      # NOTE: this is for multi-output (e.g., speech translation)
      ys_pad = pad_list(
          [
              torch.from_numpy(
                  np.array(y[0][:]) if isinstance(y, tuple) else y
              ).long()
              for y in ys
          ],
          self.ignore_id,
      ).to(device)
  
      return xs_pad, ilens, ys_pad
  
imports: import copy
  import itertools
  import json
  import logging
  import math
  import os
  import numpy
  import torch
  import torch.distributed
  from chainer import reporter
  from chainer import training
  from chainer.training import extensions
  from chainer.training.updater import StandardUpdater
  from packaging.version import parse
  from torch.nn.parallel import DistributedDataParallel
  from torch.nn.parallel import data_parallel
  from torch.utils.data.distributed import DistributedSampler
  import espnet.lm.pytorch_backend.extlm
  import espnet.nets.pytorch_backend.lm.default
  from espnet.asr.asr_utils import CompareValueTrigger, adadelta_eps_decay, add_results_to_json, format_mulenc_args, get_model_conf, plot_spectrogram, restore_snapshot, snapshot_object, torch_load, torch_resume, torch_snapshot
  from espnet.asr.pytorch_backend.asr_init import freeze_modules, load_trained_model, load_trained_modules
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.beam_search_transducer import BeamSearchTransducer
  from espnet.nets.pytorch_backend.e2e_asr import pad_list
  from espnet.nets.pytorch_backend.streaming.segment import SegmentStreamingE2E
  from espnet.nets.pytorch_backend.streaming.window import WindowStreamingE2E
  from espnet.transform.spectrogram import IStft
  from espnet.transform.transformation import Transformation
  from espnet.utils.cli_writers import file_writer_helper
  from espnet.utils.dataset import ChainerDataLoader, Transform, 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.evaluator import BaseEvaluator
  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