docstr: This module injects some information about the relative or absolute position of the tokens in the sequence.
  The generated positional encoding are concatenated together with the features.
  Args: input dim
docstr_tok: ["This","module","injects","some","information","about","the","relative","or","absolute","position","of","the","tokens","in","the","sequence",".","The","generated","positional","encoding","are","concatenated","together","with","the","features",".","Args",":","input","dim"]
code: def __init__(self, feature_dim=128, dropout=0.0, max_len=100):
      """
      This module injects some information about the relative or absolute position of the tokens in the sequence.
      The generated positional encoding are concatenated together with the features.
      Args: input dim
      """
      super(PositionalEncoding, self).__init__()
      self.dropout = nn.Dropout(p=dropout)
      pe = torch.zeros(max_len, feature_dim, requires_grad=False)
      position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(
          1
      )
      div_term = torch.exp(
          torch.arange(0, feature_dim, 2).float()
          * (-math.log(10000.0) / feature_dim)
      )
      pe[:, 0::2] = torch.sin(
          position * div_term
      )  # max_len * feature_dim // 2
      pe[:, 1::2] = torch.cos(position * div_term)
      # pe dimension: (max_len, 1, feature_dim)
      pe = pe.unsqueeze(0).transpose(0, 1)
      self.register_buffer("pe", pe)
  
imports: import logging
  import math
  from typing import List
  import torch
  import torch.nn
  import torch.nn.functional
  from reagent.core import parameters, types
  from reagent.models import convolutional_network, fully_connected_network
  from reagent.models.base import ModelBase
  from reagent.models.fully_connected_network import ACTIVATION_MAP
label_desc: Use image node_id 1 to create a new PositionalEncoding object from inherited base classes: nn with example: obj = PositionalEncoding(feature_dim, dropout, max_len)