class_docstr: Inject some information about the relative or absolute position of the tokens
      in the sequence. The positional encodings have the same dimension as
      the embeddings, so that the two can be summed. Here, we use sine and cosine
      functions of different frequencies.
  .. math::
      \text{PosEncoder}(pos, 2i) = sin(pos/10000^(2i/d_model))
      \text{PosEncoder}(pos, 2i+1) = cos(pos/10000^(2i/d_model))
      \text{where pos is the word position and i is the embed idx)
  Args:
      d_model: the embed dim (required).
      dropout: the dropout value (default=0.1).
      max_len: the max. length of the incoming sequence (default=5000).
  Examples:
      >>> pos_encoder = PositionalEncoding(d_model)
docstr: Inputs of forward function
  Args:
      x: the sequence fed to the positional encoder model (required).
  Shape:
      x: [sequence length, batch size, embed dim] if not batch_first else [B, S, D]
      output: [sequence length, batch size, embed dim] if not batch_first else [B, S, D]
  Examples:
      >>> output = pos_encoder(x)
docstr_tok: ["Inputs","of","forward","function","Args",":","x",":","the","sequence","fed","to","the","positional","encoder","model","(","required",")",".","Shape",":","x",":","[","sequence","length",",","batch","size",",","embed","dim","]","if","not","batch_first","else","[","B",",","S",",","D","]","output",":","[","sequence","length",",","batch","size",",","embed","dim","]","if","not","batch_first","else","[","B",",","S",",","D","]","Examples",":",">",">",">","output","=","pos_encoder","(","x",")"]
code: def forward(self, x):
      r"""Inputs of forward function
      Args:
          x: the sequence fed to the positional encoder model (required).
      Shape:
          x: [sequence length, batch size, embed dim] if not batch_first else [B, S, D]
          output: [sequence length, batch size, embed dim] if not batch_first else [B, S, D]
      Examples:
          >>> output = pos_encoder(x)
      """
      x = x + (
          self.pe[:, : x.size(1)]
          if self.batch_first
          else self.pe[: x.size(0)]
      )
      return self.dropout(x)
  
imports: import math
  from functools import partial
  from collections import namedtuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.utils import _pair
  import hydra
  from einops import reduce, rearrange
label_desc: Use image node_id 2 for calling the PositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: self