class_docstr: Fixed sinusoidal positional encoding.
  Args:
      d_model (int): embedding dim
      dropout_rate (float): dropout rate
      max_len (int): maximum input length
      xscale (bool): whether to scale the input by sqrt(d_model)
      dropout_rate_emb (float): dropout rate for the positional embeddings
class_docstr_tok: ["Fixed","sinusoidal","positional","encoding",".","Args",":","d_model","(","int",")",":","embedding","dim","dropout_rate","(","float",")",":","dropout","rate","max_len","(","int",")",":","maximum","input","length","xscale","(","bool",")",":","whether","to","scale","the","input","by","sqrt","(","d_model",")","dropout_rate_emb","(","float",")",":","dropout","rate","for","the","positional","embeddings"]
docstr: Adds positional encoding.
  Args:
      x (torch.Tensor): Input. Its shape is (batch, time, feature_size)
      cache_len (int): the size of the cache which is used to shift positions
  Returns:
      x+pos_emb (torch.Tensor): Its shape is (batch, time, feature_size)
      pos_emb (torch.Tensor): Its shape is (1, time, feature_size)
docstr_tok: ["Adds","positional","encoding",".","Args",":","x","(","torch.Tensor",")",":","Input",".","Its","shape","is","(","batch",",","time",",","feature_size",")","cache_len","(","int",")",":","the","size","of","the","cache","which","is","used","to","shift","positions","Returns",":","x+pos_emb","(","torch.Tensor",")",":","Its","shape","is","(","batch",",","time",",","feature_size",")","pos_emb","(","torch.Tensor",")",":","Its","shape","is","(","1",",","time",",","feature_size",")"]
code: def forward(self, x: torch.Tensor, cache_len=0):
      """Adds positional encoding.
      Args:
          x (torch.Tensor): Input. Its shape is (batch, time, feature_size)
          cache_len (int): the size of the cache which is used to shift positions
      Returns:
          x+pos_emb (torch.Tensor): Its shape is (batch, time, feature_size)
          pos_emb (torch.Tensor): Its shape is (1, time, feature_size)
      """
      input_len = x.size(1) + cache_len
      if self.xscale:
          x = x * self.xscale
      pos_emb = self.pe[:, :input_len]
      if self.dropout_emb:
          pos_emb = self.dropout_emb(pos_emb)
      x = x + pos_emb
      return self.dropout(x), pos_emb
  
imports: import math
  from functools import lru_cache
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import avoid_float16_autocast_context
label_desc: Use image node_id 4 for calling the PositionalEncoding obj's underlying member method code with example usage: obj.forward(x, cache_len) and returns: self,  pos_emb