class_docstr: Duration calculator module for FastSpeech.
  
  Todo:
      * Fix the duplicated calculation of diagonal head decision
class_docstr_tok: ["Duration","calculator","module","for","FastSpeech",".","Todo",":","*","Fix","the","duplicated","calculation","of","diagonal","head","decision"]
docstr: Initialize duration calculator module.
  
  Args:
      teacher_model (e2e_tts_transformer.Transformer):
          Pretrained auto-regressive Transformer.
docstr_tok: ["Initialize","duration","calculator","module",".","Args",":","teacher_model","(","e2e_tts_transformer.Transformer",")",":","Pretrained","auto-regressive","Transformer","."]
code: def __init__(self, teacher_model):
      """Initialize duration calculator module.
  
      Args:
          teacher_model (e2e_tts_transformer.Transformer):
              Pretrained auto-regressive Transformer.
  
      """
      super(DurationCalculator, self).__init__()
      if isinstance(teacher_model, Transformer):
          self.register_buffer("diag_head_idx", torch.tensor(-1))
      elif isinstance(teacher_model, Tacotron2):
          pass
      else:
          raise ValueError(
              "teacher model should be the instance of "
              "e2e_tts_transformer.Transformer or e2e_tts_tacotron2.Tacotron2."
          )
      self.teacher_model = teacher_model
  
file_path: espnet/espnet/nets/pytorch_backend/fastspeech/duration_calculator.py
imports: import torch
  from espnet.nets.pytorch_backend.e2e_tts_tacotron2 import Tacotron2
  from espnet.nets.pytorch_backend.e2e_tts_transformer import Transformer
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 1 to create a new DurationCalculator object from inherited base classes: torch.nn with example: obj = DurationCalculator(teacher_model)