class_docstr: Loss function module for Tacotron2.
class_docstr_tok: ["Loss","function","module","for","Tacotron2","."]
docstr: Apply pre hook function before loading state dict.
  
  From v.0.6.1 `bce_criterion.pos_weight` param is registered as a parameter but
  old models do not include it and as a result, it causes missing key error when
  loading old model parameter. This function solve the issue by adding param in
  state dict before loading as a pre hook function
  of the `load_state_dict` method.
docstr_tok: ["Apply","pre","hook","function","before","loading","state","dict",".","From","v.0.6.1","`","bce_criterion.pos_weight","`","param","is","registered","as","a","parameter","but","old","models","do","not","include","it","and","as","a","result",",","it","causes","missing","key","error","when","loading","old","model","parameter",".","This","function","solve","the","issue","by","adding","param","in","state","dict","before","loading","as","a","pre","hook","function","of","the","`","load_state_dict","`","method","."]
code: def _load_state_dict_pre_hook(
      self,
      state_dict,
      prefix,
      local_metadata,
      strict,
      missing_keys,
      unexpected_keys,
      error_msgs,
  ):
      """Apply pre hook function before loading state dict.
  
      From v.0.6.1 `bce_criterion.pos_weight` param is registered as a parameter but
      old models do not include it and as a result, it causes missing key error when
      loading old model parameter. This function solve the issue by adding param in
      state dict before loading as a pre hook function
      of the `load_state_dict` method.
  
      """
      key = prefix + "bce_criterion.pos_weight"
      if key not in state_dict:
          state_dict[key] = self.bce_criterion.pos_weight
  
imports: import logging
  import numpy
  import torch
  import torch.nn.functional
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask
  from espnet.nets.pytorch_backend.rnn.attentions import AttForward, AttForwardTA, AttLoc
  from espnet.nets.pytorch_backend.tacotron2.cbhg import CBHG, CBHGLoss
  from espnet.nets.pytorch_backend.tacotron2.decoder import Decoder
  from espnet.nets.pytorch_backend.tacotron2.encoder import Encoder
  from espnet.nets.tts_interface import TTSInterface
  from espnet.utils.cli_utils import strtobool
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 3 for calling the Tacotron2Loss obj's underlying member method code with example usage: obj._load_state_dict_pre_hook(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs) without return types