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)
code: def __init__(
      self,
      d_model,
      dropout=0.1,
      max_len=5000,
      batch_first=False,
      initializer=None,
  ):
      super().__init__()
      self.batch_first = batch_first
      self.dropout = nn.Dropout(p=dropout)
      pe = torch.empty(max_len, d_model)
      if initializer is None:
          sinusoidal_init_(pe)
          pe = rearrange(
              pe, "s d -> 1 s d" if self.batch_first else "s d -> s 1 d"
          )
          self.register_buffer("pe", pe)
      else:
          hydra.utils.call(initializer, pe)
          pe = rearrange(
              pe, "s d -> 1 s d" if self.batch_first else "s d -> s 1 d"
          )
          self.pe = nn.Parameter(pe)
  
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 1 to create a new PositionalEncoding object from inherited base classes: nn with example: obj = PositionalEncoding(d_model, dropout, max_len, batch_first, initializer)