class_docstr: A Transformer-based Grapheme-to-Phoneme model
  
  Arguments
  ----------
  emb: torch.nn.Module
      the embedding module
  encoder_emb: torch.nn.Module
      the encoder embedding module
  char_lin: torch.nn.Module
      a linear module connecting the inputs
      to the transformer
  phn_lin: torch.nn.Module
      a linear module connecting the outputs to
      the transformer
  out: torch.nn.Module
      the decoder module (usually Softmax)
  lin: torch.nn.Module
      the linear module for outputs
  d_model: int
      The number of expected features in the encoder/decoder inputs (default=512).
  nhead: int
      The number of heads in the multi-head attention models (default=8).
  num_encoder_layers: int, optional
      The number of encoder layers in1ì the encoder.
  num_decoder_layers: int, optional
      The number of decoder layers in the decoder.
  dim_ffn: int, optional
      The dimension of the feedforward network model hidden layer.
  dropout: int, optional
      The dropout value.
  activation: torch.nn.Module, optional
      The activation function for Feed-Forward Netowrk layer,
      e.g., relu or gelu or swish.
  custom_src_module: torch.nn.Module, optional
      Module that processes the src features to expected feature dim.
  custom_tgt_module: torch.nn.Module, optional
      Module that processes the src features to expected feature dim.
  positional_encoding: str, optional
      Type of positional encoding used. e.g. 'fixed_abs_sine' for fixed absolute positional encodings.
  normalize_before: bool, optional
      Whether normalization should be applied before or after MHA or FFN in Transformer layers.
      Defaults to True as this was shown to lead to better performance and training stability.
  kernel_size: int, optional
      Kernel size in convolutional layers when Conformer is used.
  bias: bool, optional
      Whether to use bias in Conformer convolutional layers.
  encoder_module: str, optional
      Choose between Conformer and Transformer for the encoder. The decoder is fixed to be a Transformer.
  conformer_activation: torch.nn.Module, optional
      Activation module used after Conformer convolutional layers. E.g. Swish, ReLU etc. it has to be a torch Module.
  attention_type: str, optional
      Type of attention layer used in all Transformer or Conformer layers.
      e.g. regularMHA or RelPosMHA.
  max_length: int, optional
      Max length for the target and source sequence in input.
      Used for positional encodings.
  causal: bool, optional
      Whether the encoder should be causal or not (the decoder is always causal).
      If causal the Conformer convolutional layer is causal.
  pad_idx: int
      the padding index (for masks)
  encoder_kdim: int, optional
      Dimension of the key for the encoder.
  encoder_vdim: int, optional
      Dimension of the value for the encoder.
  decoder_kdim: int, optional
      Dimension of the key for the decoder.
  decoder_vdim: int, optional
      Dimension of the value for the decoder.
docstr: This method implements a decoding step for the transformer model.
  
  Arguments
  ---------
  tgt : torch.Tensor
      The sequence to the decoder.
  encoder_out : torch.Tensor
      Hidden output of the encoder.
  
  Returns
  -------
  prediction: torch.Tensor
      the predicted sequence
  attention: torch.Tensor
      the attention matrix corresponding to the last attention head
      (useful for plotting attention)
docstr_tok: ["This","method","implements","a","decoding","step","for","the","transformer","model",".","Arguments","--","--","--","--","-","tgt",":","torch.Tensor","The","sequence","to","the","decoder",".","encoder_out",":","torch.Tensor","Hidden","output","of","the","encoder",".","Returns","--","--","--","-","prediction",":","torch.Tensor","the","predicted","sequence","attention",":","torch.Tensor","the","attention","matrix","corresponding","to","the","last","attention","head","(","useful","for","plotting","attention",")"]
code: def decode(self, tgt, encoder_out, enc_lens):
      """This method implements a decoding step for the transformer model.
  
      Arguments
      ---------
      tgt : torch.Tensor
          The sequence to the decoder.
      encoder_out : torch.Tensor
          Hidden output of the encoder.
  
      Returns
      -------
      prediction: torch.Tensor
          the predicted sequence
      attention: torch.Tensor
          the attention matrix corresponding to the last attention head
          (useful for plotting attention)
      """
      tgt_mask = get_lookahead_mask(tgt)
      tgt = self.emb(tgt)
      tgt = self.phn_lin(tgt)
      if self.attention_type == "RelPosMHAXL":
          # we use fixed positional encodings in the decoder
          tgt = tgt + self.positional_encoding_decoder(tgt)
          encoder_out = encoder_out + self.positional_encoding_decoder(
              encoder_out
          )
      elif self.positional_encoding_type == "fixed_abs_sine":
          tgt = tgt + self.positional_encoding(
              tgt
          )  # add the encodings here
      prediction, self_attns, multihead_attns = self.decoder(
          tgt,
          encoder_out,
          tgt_mask=tgt_mask,
          pos_embs_tgt=None,
          pos_embs_src=None,
      )
      attention = multihead_attns[-1]
      return prediction, attention
  
imports: from speechbrain.lobes.models.transformer.Transformer import TransformerInterface, get_lookahead_mask, get_key_padding_mask
  import torch
  from torch import nn
  from speechbrain.nnet.linear import Linear
  from speechbrain.nnet import normalization
label_desc: Use image node_id 5 for calling the TransformerG2P obj's underlying member method code with example usage: obj.decode(tgt, encoder_out, enc_lens) and returns: prediction,  attention