class_docstr: A custom evaluator for a pytorch LM.
class_docstr_tok: ["A","custom","evaluator","for","a","pytorch","LM","."]
docstr: Initialize class.
  
  :param chainer.dataset.Iterator val_iter : The validation iterator
  :param LMInterface eval_model : The model to evaluate
  :param chainer.Reporter reporter : The observations reporter
  :param int device : The device id to use
docstr_tok: ["Initialize","class",".",":","param","chainer.dataset.Iterator","val_iter",":","The","validation","iterator",":","param","LMInterface","eval_model",":","The","model","to","evaluate",":","param","chainer.Reporter","reporter",":","The","observations","reporter",":","param","int","device",":","The","device","id","to","use"]
code: def __init__(self, val_iter, eval_model, reporter, device):
      """Initialize class.
  
      :param chainer.dataset.Iterator val_iter : The validation iterator
      :param LMInterface eval_model : The model to evaluate
      :param chainer.Reporter reporter : The observations reporter
      :param int device : The device id to use
  
      """
      super(LMEvaluator, self).__init__(val_iter, reporter, device=-1)
      self.model = eval_model
      self.device = device
  
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 LMEvaluator object from inherited base classes: BaseEvaluator with example: obj = LMEvaluator(val_iter, eval_model, reporter, device)