class_docstr: An updater for a pytorch LM.
class_docstr_tok: ["An","updater","for","a","pytorch","LM","."]
docstr: Initialize class.
  
  Args:
      train_iter (chainer.dataset.Iterator): The train iterator
      model (LMInterface) : The model to update
      optimizer (torch.optim.Optimizer): The optimizer for training
      schedulers (espnet.scheduler.scheduler.SchedulerInterface):
          The schedulers of `optimizer`
      device (int): The device id
      gradclip (float): The gradient clipping value to use
      use_apex (bool): The flag to use Apex in backprop.
      accum_grad (int): The number of gradient accumulation.
docstr_tok: ["Initialize","class",".","Args",":","train_iter","(","chainer.dataset.Iterator",")",":","The","train","iterator","model","(","LMInterface",")",":","The","model","to","update","optimizer","(","torch.optim.Optimizer",")",":","The","optimizer","for","training","schedulers","(","espnet.scheduler.scheduler.SchedulerInterface",")",":","The","schedulers","of","`","optimizer","`","device","(","int",")",":","The","device","id","gradclip","(","float",")",":","The","gradient","clipping","value","to","use","use_apex","(","bool",")",":","The","flag","to","use","Apex","in","backprop",".","accum_grad","(","int",")",":","The","number","of","gradient","accumulation","."]
code: def __init__(
      self,
      train_iter,
      model,
      optimizer,
      schedulers,
      device,
      gradclip=None,
      use_apex=False,
      accum_grad=1,
  ):
      """Initialize class.
  
      Args:
          train_iter (chainer.dataset.Iterator): The train iterator
          model (LMInterface) : The model to update
          optimizer (torch.optim.Optimizer): The optimizer for training
          schedulers (espnet.scheduler.scheduler.SchedulerInterface):
              The schedulers of `optimizer`
          device (int): The device id
          gradclip (float): The gradient clipping value to use
          use_apex (bool): The flag to use Apex in backprop.
          accum_grad (int): The number of gradient accumulation.
  
      """
      super(BPTTUpdater, self).__init__(train_iter, optimizer)
      self.model = model
      self.device = device
      self.gradclip = gradclip
      self.use_apex = use_apex
      self.scheduler = PyTorchScheduler(schedulers, optimizer)
      self.accum_grad = accum_grad
  
imports: import copy
  import json
  import logging
  import numpy
  import torch
  import torch.nn
  from chainer import Chain, reporter, training
  from chainer.dataset import convert
  from chainer.training import extensions
  from torch.nn.parallel import data_parallel
  from espnet.asr.asr_utils import snapshot_object, torch_load, torch_resume, torch_snapshot
  from espnet.lm.lm_utils import MakeSymlinkToBestModel, ParallelSentenceIterator, count_tokens, load_dataset, read_tokens
  from espnet.nets.lm_interface import LMInterface, dynamic_import_lm
  from espnet.optimizer.factory import dynamic_import_optimizer
  from espnet.scheduler.pytorch import PyTorchScheduler
  from espnet.scheduler.scheduler import dynamic_import_scheduler
  from espnet.utils.deterministic_utils import set_deterministic_pytorch
  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 1 to create a new BPTTUpdater object from inherited base classes: training with example: obj = BPTTUpdater(train_iter, model, optimizer, schedulers, device, gradclip, use_apex, accum_grad)