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: Add positional encoding.
  Args:
      x (torch.Tensor): Input tensor B X T X C
  Returns:
      torch.Tensor: Encoded tensor B X T X C
docstr_tok: ["Add","positional","encoding",".","Args",":","x","(","torch.Tensor",")",":","Input","tensor","B","X","T","X","C","Returns",":","torch.Tensor",":","Encoded","tensor","B","X","T","X","C"]
code: def forward(self, x: torch.Tensor):
      """Add positional encoding.
      Args:
          x (torch.Tensor): Input tensor B X T X C
      Returns:
          torch.Tensor: Encoded tensor B X T X C
      """
      self.extend_pe(x)
      x = x * self.xscale + self.pe[:, : x.size(1)]
      return self.dropout(x)
  
file_path: fairseq/fairseq/modules/positional_encoding.py
imports: import torch.nn
  import math
  import torch
label_desc: Use image node_id 3 for calling the PositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: self