class_docstr: Positional encoding.
  
  Args:
      d_model: Embedding dimension.
      dropout_rate: Dropout rate.
      max_len: Maximum input length.
      reverse: Whether to reverse the input position.
class_docstr_tok: ["Positional","encoding",".","Args",":","d_model",":","Embedding","dimension",".","dropout_rate",":","Dropout","rate",".","max_len",":","Maximum","input","length",".","reverse",":","Whether","to","reverse","the","input","position","."]
docstr: Construct an PositionalEncoding object.
docstr_tok: ["Construct","an","PositionalEncoding","object","."]
code: def __init__(
      self, d_model, dropout_rate, max_len=5000, reverse=False
  ):
      """Construct an PositionalEncoding object."""
      super(PositionalEncoding, self).__init__()
      self.d_model = d_model
      self.reverse = reverse
      self.xscale = math.sqrt(self.d_model)
      self.dropout = nn.Dropout(p=dropout_rate)
      self.pe = None
      self.extend_pe(torch.tensor(0.0).expand(1, max_len))
  
file_path: fairseq/fairseq/modules/positional_encoding.py
imports: import torch.nn
  import math
  import torch
label_desc: Use image node_id 1 to create a new PositionalEncoding object from inherited base classes: nn with example: obj = PositionalEncoding(d_model, dropout_rate, max_len, reverse)