class_docstr: A wrapper for pytorch RNNLM.
class_docstr_tok: ["A","wrapper","for","pytorch","RNNLM","."]
docstr: Initialize class.
  
  :param torch.nn.Module predictor : The RNNLM
  :param function lossfun : The loss function to use
  :param int/str label_key :
docstr_tok: ["Initialize","class",".",":","param","torch.nn.Module","predictor",":","The","RNNLM",":","param","function","lossfun",":","The","loss","function","to","use",":","param","int\/str","label_key",":"]
code: def __init__(
      self,
      predictor,
      lossfun=nn.CrossEntropyLoss(reduction="none"),
      label_key=-1,
  ):
      """Initialize class.
  
      :param torch.nn.Module predictor : The RNNLM
      :param function lossfun : The loss function to use
      :param int/str label_key :
  
      """
      if not (isinstance(label_key, (int, str))):
          raise TypeError(
              "label_key must be int or str, but is %s"
              % type(label_key)
          )
      super(ClassifierWithState, self).__init__()
      self.lossfun = lossfun
      self.y = None
      self.loss = None
      self.label_key = label_key
      self.predictor = predictor
  
imports: import logging
  from typing import Any, List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from espnet.nets.lm_interface import LMInterface
  from espnet.nets.pytorch_backend.e2e_asr import to_device
  from espnet.nets.scorer_interface import BatchScorerInterface
  from espnet.utils.cli_utils import strtobool
label_desc: Use image node_id 1 to create a new ClassifierWithState object from inherited base classes: nn with example: obj = ClassifierWithState(predictor, lossfun, label_key)