class_docstr: Scaled positional encoding module.
  
  See Sec. 3.2  https://arxiv.org/abs/1809.08895
  
  Args:
      d_model (int): Embedding dimension.
      dropout_rate (float): Dropout rate.
      max_len (int): Maximum input length.
class_docstr_tok: ["Scaled","positional","encoding","module",".","See","Sec",".","3.2","https",":","\/\/arxiv.org\/abs\/1809.08895","Args",":","d_model","(","int",")",":","Embedding","dimension",".","dropout_rate","(","float",")",":","Dropout","rate",".","max_len","(","int",")",":","Maximum","input","length","."]
docstr: Add positional encoding.
  
  Args:
      x (torch.Tensor): Input tensor (batch, time, `*`).
  
  Returns:
      torch.Tensor: Encoded tensor (batch, time, `*`).
docstr_tok: ["Add","positional","encoding",".","Args",":","x","(","torch.Tensor",")",":","Input","tensor","(","batch",",","time",",","`","*","`",")",".","Returns",":","torch.Tensor",":","Encoded","tensor","(","batch",",","time",",","`","*","`",")","."]
code: def forward(self, x):
      """Add positional encoding.
  
      Args:
          x (torch.Tensor): Input tensor (batch, time, `*`).
  
      Returns:
          torch.Tensor: Encoded tensor (batch, time, `*`).
  
      """
      self.extend_pe(x)
      x = x + self.alpha * self.pe[:, : x.size(1)]
      return self.dropout(x)
  
imports: import math
  import torch
label_desc: Use image node_id 3 for calling the ScaledPositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: self