class_docstr: Applies a positional encoding to a tensor with shape (batch_size x seq_len x embed_dim).
  
  The positional encoding is computed as follows:
      PE(pos,2i) = sin(pos/10000^(2i/dmodel))
      PE(pos,2i+1) = cos(pos/10000^(2i/dmodel))
  
      where pos = position, pos in [0, seq_len)
      dmodel = data embedding dimension = embed_dim
      i = dimension index, i in [0, embed_dim)
  
  Reference: "Attention Is All You Need" https://arxiv.org/abs/1706.03762
  Implementation Reference: https://pytorch.org/tutorials/beginner/transformer_tutorial.html
class_docstr_tok: ["Applies","a","positional","encoding","to","a","tensor","with","shape","(","batch_size","x","seq_len","x","embed_dim",")",".","The","positional","encoding","is","computed","as","follows",":","PE","(","pos,2i",")","=","sin","(","pos\/10000^","(","2i\/dmodel",")",")","PE","(","pos,2i+1",")","=","cos","(","pos\/10000^","(","2i\/dmodel",")",")","where","pos","=","position",",","pos","in","[","0",",","seq_len",")","dmodel","=","data","embedding","dimension","=","embed_dim","i","=","dimension","index",",","i","in","[","0",",","embed_dim",")","Reference",":","``","Attention","Is","All","You","Need","''","https",":","\/\/arxiv.org\/abs\/1706.03762","Implementation","Reference",":","https",":","\/\/pytorch.org\/tutorials\/beginner\/transformer_tutorial.html"]
code: def __init__(self, embed_dim: int, seq_len: int = 1024) -> None:
      super().__init__()
      pe = torch.zeros(seq_len, embed_dim, dtype=torch.float)
      position = torch.arange(0, seq_len, dtype=torch.float).unsqueeze(
          1
      )
      div_term = torch.exp(
          torch.arange(0, embed_dim, 2).float()
          * (-(math.log(10000.0)) / embed_dim)
      )
      pe[:, 0::2] = torch.sin(position * div_term)
      pe[:, 1::2] = torch.cos(position * div_term)
      pe = pe.unsqueeze(0)
      self.register_buffer("pe", pe)
  
file_path: pytorchvideo/pytorchvideo/layers/positional_encoding.py
imports: import math
  from typing import Tuple
  import numpy
  import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new PositionalEncoding object from inherited base classes: nn with example: obj = PositionalEncoding(embed_dim, seq_len)