class_docstr: Sinusoidal positional encodings
  
  Using the scaling term from https://github.com/megvii-research/CREStereo/blob/master/nets/attention/position_encoding.py
  Reference implementation from https://github.com/facebookresearch/detr/blob/8a144f83a287f4d3fece4acdf073f387c5af387d/models/position_encoding.py#L28-L48
class_docstr_tok: ["Sinusoidal","positional","encodings","Using","the","scaling","term","from","https",":","\/\/github.com\/megvii-research\/CREStereo\/blob\/master\/nets\/attention\/position_encoding.py","Reference","implementation","from","https",":","\/\/github.com\/facebookresearch\/detr\/blob\/8a144f83a287f4d3fece4acdf073f387c5af387d\/models\/position_encoding.py","#","L28-L48"]
docstr: Args:
      x: [B, C, H, W]
  
  Returns:
      x: [B, C, H, W]
docstr_tok: ["Args",":","x",":","[","B",",","C",",","H",",","W","]","Returns",":","x",":","[","B",",","C",",","H",",","W","]"]
code: def forward(self, x: Tensor) -> Tensor:
      """
      Args:
          x: [B, C, H, W]
  
      Returns:
          x: [B, C, H, W]
      """
      torch._assert(
          len(x.shape) == 4,
          f"PositionalEncodingSine requires a 4-D dimensional input. Provided tensor is of shape {x.shape}",
      )
  
      B, C, H, W = x.shape
      return x + self.pe[:, :, :H, :W]
  
imports: import math
  from functools import partial
  from typing import Callable, Dict, Iterable, List, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torchvision.models.optical_flow.raft
  from torch import Tensor
  from torchvision.models._api import register_model, Weights, WeightsEnum
  from torchvision.models._utils import handle_legacy_interface
  from torchvision.models.optical_flow._utils import grid_sample, make_coords_grid, upsample_flow
  from torchvision.ops import Conv2dNormActivation
  from torchvision.prototype.transforms._presets import StereoMatching
label_desc: Use image node_id 3 for calling the PositionalEncodingSine obj's underlying member method code with example usage: obj.forward(x) and returns: unknown