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(tuple(str, dict[str, dict[str, Any]]))): The batch to transform.
      device (torch.device): The device to send to.
  
  Returns:
      tuple(torch.Tensor, torch.Tensor, torch.Tensor): Transformed batch.
docstr_tok: ["Transform","a","batch","and","send","it","to","a","device",".","Args",":","batch","(","list","(","tuple","(","str",",","dict","[","str",",","dict","[","str",",","Any","]","]",")",")",")",":","The","batch","to","transform",".","device","(","torch.device",")",":","The","device","to","send","to",".","Returns",":","tuple","(","torch.Tensor",",","torch.Tensor",",","torch.Tensor",")",":","Transformed","batch","."]
code: def __call__(self, batch, device=torch.device("cpu")):
      """Transform a batch and send it to a device.
  
      Args:
          batch (list(tuple(str, dict[str, dict[str, Any]]))): The batch to transform.
          device (torch.device): The device to send to.
  
      Returns:
          tuple(torch.Tensor, torch.Tensor, torch.Tensor): Transformed batch.
  
      """
      # batch should be located in list
      assert len(batch) == 1
      xs, ys = batch[0][0], batch[0][-self.num_spkrs :]
  
      # 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 to E2E here
          # because torch.nn.DataParallel 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)
      if not isinstance(ys[0], np.ndarray):
          ys_pad = []
          for i in range(len(ys)):  # speakers
              ys_pad += [torch.from_numpy(y).long() for y in ys[i]]
          ys_pad = pad_list(ys_pad, self.ignore_id)
          ys_pad = (
              ys_pad.view(self.num_spkrs, -1, ys_pad.size(1))
              .transpose(0, 1)
              .to(device)
          )  # (B, num_spkrs, Tmax)
      else:
          ys_pad = pad_list(
              [torch.from_numpy(y).long() for y in ys], self.ignore_id
          ).to(device)
  
      return xs_pad, ilens, ys_pad
  
imports: import json
  import logging
  import os
  from itertools import zip_longest
  import numpy
  import torch
  from chainer import training
  from chainer.training import extensions
  import espnet.lm.pytorch_backend.extlm
  import espnet.nets.pytorch_backend.lm.default
  from espnet.asr.asr_mix_utils import add_results_to_json
  from espnet.asr.asr_utils import CompareValueTrigger, adadelta_eps_decay, get_model_conf, restore_snapshot, snapshot_object, torch_load, torch_resume, torch_snapshot
  from espnet.asr.pytorch_backend.asr import CustomEvaluator, CustomUpdater, load_trained_model
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.pytorch_backend.e2e_asr_mix import pad_list
  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