class_docstr: General forward TTS model implementation that uses an encoder-decoder architecture with an optional alignment
  network and a pitch predictor.
  
  If the alignment network is used, the model learns the text-to-speech alignment
  from the data instead of using pre-computed durations.
  
  If the pitch predictor is used, the model trains a pitch predictor that predicts average pitch value for each
  input character as in the FastPitch model.
  
  `ForwardTTS` can be configured to one of these architectures,
  
      - FastPitch
      - SpeedySpeech
      - FastSpeech
      - FastSpeech2 (requires average speech energy predictor)
  
  Args:
      config (Coqpit): Model coqpit class.
      speaker_manager (SpeakerManager): Speaker manager for multi-speaker training. Only used for multi-speaker models.
          Defaults to None.
  
  Examples:
      >>> from TTS.tts.models.fast_pitch import ForwardTTS, ForwardTTSArgs
      >>> config = ForwardTTSArgs()
      >>> model = ForwardTTS(config)
class_docstr_tok: ["General","forward","TTS","model","implementation","that","uses","an","encoder-decoder","architecture","with","an","optional","alignment","network","and","a","pitch","predictor",".","If","the","alignment","network","is","used",",","the","model","learns","the","text-to-speech","alignment","from","the","data","instead","of","using","pre-computed","durations",".","If","the","pitch","predictor","is","used",",","the","model","trains","a","pitch","predictor","that","predicts","average","pitch","value","for","each","input","character","as","in","the","FastPitch","model",".","`","ForwardTTS","`","can","be","configured","to","one","of","these","architectures",",","-","FastPitch","-","SpeedySpeech","-","FastSpeech","-","FastSpeech2","(","requires","average","speech","energy","predictor",")","Args",":","config","(","Coqpit",")",":","Model","coqpit","class",".","speaker_manager","(","SpeakerManager",")",":","Speaker","manager","for","multi-speaker","training",".","Only","used","for","multi-speaker","models",".","Defaults","to","None",".","Examples",":",">",">",">","from","TTS.tts.models.fast_pitch","import","ForwardTTS",",","ForwardTTSArgs",">",">",">","config","=","ForwardTTSArgs","(",")",">",">",">","model","=","ForwardTTS","(","config",")"]
docstr: Pitch predictor forward pass.
  
  1. Predict pitch from encoder outputs.
  2. In training - Compute average pitch values for each input character from the ground truth pitch values.
  3. Embed average pitch values.
  
  Args:
      o_en (torch.FloatTensor): Encoder output.
      x_mask (torch.IntTensor): Input sequence mask.
      pitch (torch.FloatTensor, optional): Ground truth pitch values. Defaults to None.
      dr (torch.IntTensor, optional): Ground truth durations. Defaults to None.
  
  Returns:
      Tuple[torch.FloatTensor, torch.FloatTensor]: Pitch embedding, pitch prediction.
  
  Shapes:
      - o_en: :math:`(B, C, T_{en})`
      - x_mask: :math:`(B, 1, T_{en})`
      - pitch: :math:`(B, 1, T_{de})`
      - dr: :math:`(B, T_{en})`
code: def _forward_pitch_predictor(
      self,
      o_en: torch.FloatTensor,
      x_mask: torch.IntTensor,
      pitch: torch.FloatTensor = None,
      dr: torch.IntTensor = None,
  ) -> Tuple[torch.FloatTensor, torch.FloatTensor]:
      """Pitch predictor forward pass.
  
      1. Predict pitch from encoder outputs.
      2. In training - Compute average pitch values for each input character from the ground truth pitch values.
      3. Embed average pitch values.
  
      Args:
          o_en (torch.FloatTensor): Encoder output.
          x_mask (torch.IntTensor): Input sequence mask.
          pitch (torch.FloatTensor, optional): Ground truth pitch values. Defaults to None.
          dr (torch.IntTensor, optional): Ground truth durations. Defaults to None.
  
      Returns:
          Tuple[torch.FloatTensor, torch.FloatTensor]: Pitch embedding, pitch prediction.
  
      Shapes:
          - o_en: :math:`(B, C, T_{en})`
          - x_mask: :math:`(B, 1, T_{en})`
          - pitch: :math:`(B, 1, T_{de})`
          - dr: :math:`(B, T_{en})`
      """
      o_pitch = self.pitch_predictor(o_en, x_mask)
      if pitch is not None:
          avg_pitch = average_over_durations(pitch, dr)
          o_pitch_emb = self.pitch_emb(avg_pitch)
          return o_pitch_emb, o_pitch, avg_pitch
      o_pitch_emb = self.pitch_emb(o_pitch)
      return o_pitch_emb, o_pitch
  
imports: from dataclasses import dataclass, field
  from typing import Dict, List, Tuple, Union
  import torch
  from coqpit import Coqpit
  from torch import nn
  from torch.cuda.amp.autocast_mode import autocast
  from TTS.tts.layers.feed_forward.decoder import Decoder
  from TTS.tts.layers.feed_forward.encoder import Encoder
  from TTS.tts.layers.generic.aligner import AlignmentNetwork
  from TTS.tts.layers.generic.pos_encoding import PositionalEncoding
  from TTS.tts.layers.glow_tts.duration_predictor import DurationPredictor
  from TTS.tts.models.base_tts import BaseTTS
  from TTS.tts.utils.helpers import average_over_durations, generate_path, maximum_path, sequence_mask
  from TTS.tts.utils.speakers import SpeakerManager
  from TTS.tts.utils.text.tokenizer import TTSTokenizer
  from TTS.tts.utils.visual import plot_alignment, plot_avg_energy, plot_avg_pitch, plot_spectrogram
  from TTS.utils.io import load_fsspec
label_desc: Use image node_id 8 for calling the ForwardTTS obj's underlying member method code with example usage: obj._forward_pitch_predictor(o_en, x_mask, pitch, dr) and returns: o_pitch_emb,  o_pitch, o_pitch_emb,  o_pitch,  avg_pitch