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: Construct an PositionalEncoding object.
docstr_tok: ["Construct","an","PositionalEncoding","object","."]
code: def __init__(
      self,
      d_model,
      dropout_rate,
      max_len=5000,
      xscale=None,
      dropout_rate_emb=0.0,
  ):
      """Construct an PositionalEncoding object."""
      super(PositionalEncoding, self).__init__()
      self.d_model = d_model
      self.xscale = xscale
      self.dropout = torch.nn.Dropout(p=dropout_rate)
      self.max_len = max_len
      if dropout_rate_emb > 0:
          self.dropout_emb = nn.Dropout(dropout_rate_emb)
      else:
          self.dropout_emb = None
  
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 1 to create a new PositionalEncoding object from inherited base classes: torch.nn with example: obj = PositionalEncoding(d_model, dropout_rate, max_len, xscale, dropout_rate_emb)