code: def forward(
      self,
      *,
      text,
      durs=None,
      pitch=None,
      energy=None,
      speaker=None,
      pace=1.0,
      spec=None,
      attn_prior=None,
      mel_lens=None,
      input_lens=None,
      reference_spec=None,
      reference_spec_lens=None,
  ):
      if not self.learn_alignment and self.training:
          assert durs is not None
          assert pitch is not None
  
      # Calculate speaker embedding
      spk_emb = self.get_speaker_embedding(
          batch_size=text.shape[0],
          speaker=speaker,
          reference_spec=reference_spec,
          reference_spec_lens=reference_spec_lens,
      )
  
      # Input FFT
      enc_out, enc_mask = self.encoder(input=text, conditioning=spk_emb)
  
      # Predict duration
      log_durs_predicted = self.duration_predictor(
          enc_out, enc_mask, conditioning=spk_emb
      )
      durs_predicted = log_to_duration(
          log_dur=log_durs_predicted,
          min_dur=self.min_token_duration,
          max_dur=self.max_token_duration,
          mask=enc_mask,
      )
  
      attn_soft, attn_hard, attn_hard_dur, attn_logprob = (
          None,
          None,
          None,
          None,
      )
      if self.learn_alignment and spec is not None:
          text_emb = self.encoder.word_emb(text)
          attn_soft, attn_logprob = self.aligner(
              spec,
              text_emb.permute(0, 2, 1),
              enc_mask == 0,
              attn_prior,
              conditioning=spk_emb,
          )
          attn_hard = binarize_attention_parallel(
              attn_soft, input_lens, mel_lens
          )
          attn_hard_dur = attn_hard.sum(2)[:, 0, :]
  
      # Predict pitch
      pitch_predicted = self.pitch_predictor(
          enc_out, enc_mask, conditioning=spk_emb
      )
      if pitch is not None:
          if (
              self.learn_alignment
              and pitch.shape[-1] != pitch_predicted.shape[-1]
          ):
              # Pitch during training is per spectrogram frame, but during inference, it should be per character
              pitch = average_features(
                  pitch.unsqueeze(1), attn_hard_dur
              ).squeeze(1)
          elif not self.learn_alignment:
              # If alignment is not learnt attn_hard_dur is None, hence durs_predicted
              pitch = average_features(
                  pitch.unsqueeze(1), durs_predicted
              ).squeeze(1)
          pitch_emb = self.pitch_emb(pitch.unsqueeze(1))
      else:
          pitch_emb = self.pitch_emb(pitch_predicted.unsqueeze(1))
  
      enc_out = enc_out + pitch_emb.transpose(1, 2)
  
      # Predict energy
      if self.energy_predictor is not None:
          energy_pred = self.energy_predictor(
              enc_out, enc_mask, conditioning=spk_emb
          ).squeeze(-1)
  
          if energy is not None:
              # Average energy over characters
              if self.learn_alignment:
                  energy_tgt = average_features(
                      energy.unsqueeze(1), attn_hard_dur
                  )
              else:
                  energy_tgt = average_features(
                      energy.unsqueeze(1), durs_predicted
                  )
              if self.use_log_energy:
                  energy_tgt = torch.log(1.0 + energy_tgt)
              energy_emb = self.energy_emb(energy_tgt)
              energy_tgt = energy_tgt.squeeze(1)
          else:
              energy_emb = self.energy_emb(energy_pred.unsqueeze(1))
              energy_tgt = None
  
          enc_out = enc_out + energy_emb.transpose(1, 2)
      else:
          energy_pred = None
          energy_tgt = None
  
      if self.learn_alignment and spec is not None:
          len_regulated, dec_lens = regulate_len(
              attn_hard_dur, enc_out, pace
          )
      elif spec is None and durs is not None:
          len_regulated, dec_lens = regulate_len(durs, enc_out, pace)
      # Use predictions during inference
      elif spec is None:
          len_regulated, dec_lens = regulate_len(
              durs_predicted, enc_out, pace
          )
      else:
          raise ValueError(
              f"Something unexpected happened when 'spec' is not None and 'self.learn_alignment' is False."
          )
  
      # Output FFT
      dec_out, _ = self.decoder(
          input=len_regulated, seq_lens=dec_lens, conditioning=spk_emb
      )
      spect = self.proj(dec_out).transpose(1, 2)
      return (
          spect,
          dec_lens,
          durs_predicted,
          log_durs_predicted,
          pitch_predicted,
          attn_soft,
          attn_logprob,
          attn_hard,
          attn_hard_dur,
          pitch,
          energy_pred,
          energy_tgt,
      )
  
imports: import torch
  from nemo.collections.tts.modules.submodules import ConditionalInput, ConditionalLayerNorm
  from nemo.collections.tts.parts.utils.helpers import binarize_attention_parallel, regulate_len
  from nemo.core.classes import NeuralModule, adapter_mixins, typecheck
  from nemo.core.neural_types.elements import EncodedRepresentation, Index, LengthsType, LogprobsType, MelSpectrogramType, ProbsType, RegressionValuesType, TokenDurationType, TokenIndex, TokenLogDurationType
  from nemo.core.neural_types.neural_type import NeuralType
label_desc: Use image node_id 5 for calling the FastPitchModule obj's underlying member method code with example usage: obj.forward() and returns: spect,  dec_lens,  durs_predicted,  log_durs_predicted,  pitch_predicted,  attn_soft,  attn_logprob,  attn_hard,  attn_hard_dur,  pitch,  energy_pred,  energy_tgt