class_docstr: Add a cls token and apply a spatiotemporal encoding to a tensor.
class_docstr_tok: ["Add","a","cls","token","and","apply","a","spatiotemporal","encoding","to","a","tensor","."]
docstr: Args:
      x (torch.Tensor): Input tensor.
docstr_tok: ["Args",":","x","(","torch.Tensor",")",":","Input","tensor","."]
code: def forward(self, x: torch.Tensor) -> torch.Tensor:
      """
      Args:
          x (torch.Tensor): Input tensor.
      """
      B, N, C = x.shape
      if self.cls_embed_on:
          cls_tokens = self.cls_token.expand(B, -1, -1)
          x = torch.cat((cls_tokens, x), dim=1)
  
      if self.sep_pos_embed:
          pos_embed = self.pos_embed_spatial.repeat(
              1, self.num_temporal_patch, 1
          ) + torch.repeat_interleave(
              self.pos_embed_temporal,
              self.num_spatial_patch,
              dim=1,
          )
          if self.cls_embed_on:
              pos_embed = torch.cat(
                  [self.pos_embed_class, pos_embed], 1
              )
          x = x + pos_embed
      else:
          x = x + self.pos_embed
  
      return x
  
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 3 for calling the SpatioTemporalClsPositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: x