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 forward(self, x: torch.Tensor) -> torch.Tensor:
      assert self.pe.size(1) >= x.size(1), (
          "Cannot apply position encoding of size "
          + f"{self.pe.size()} when input has size {x.size()}"
      )
      return x + self.pe[:, : x.size(1), :]
  
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 2 for calling the PositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: unknown