class_docstr: Position encoding with sine and cosine functions.
  
  See `End-to-End Object Detection with Transformers
  <https://arxiv.org/pdf/2005.12872>`_ for details.
  
  Args:
      num_feats (int): The feature dimension for each position
          along x-axis or y-axis. Note the final returned dimension
          for each position is 2 times of this value.
      temperature (int, optional): The temperature used for scaling
          the position embedding. Defaults to 10000.
      normalize (bool, optional): Whether to normalize the position
          embedding. Defaults to False.
      scale (float, optional): A scale factor that scales the position
          embedding. The scale will be used only when `normalize` is True.
          Defaults to 2*pi.
      eps (float, optional): A value added to the denominator for
          numerical stability. Defaults to 1e-6.
      offset (float): offset add to embed when do the normalization.
          Defaults to 0.
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Defaults to None
class_docstr_tok: ["Position","encoding","with","sine","and","cosine","functions",".","See","`","End-to-End","Object","Detection","with","Transformers","<","https",":","\/\/arxiv.org\/pdf\/2005.12872",">","`","_","for","details",".","Args",":","num_feats","(","int",")",":","The","feature","dimension","for","each","position","along","x-axis","or","y-axis",".","Note","the","final","returned","dimension","for","each","position","is","2","times","of","this","value",".","temperature","(","int",",","optional",")",":","The","temperature","used","for","scaling","the","position","embedding",".","Defaults","to","10000.","normalize","(","bool",",","optional",")",":","Whether","to","normalize","the","position","embedding",".","Defaults","to","False",".","scale","(","float",",","optional",")",":","A","scale","factor","that","scales","the","position","embedding",".","The","scale","will","be","used","only","when","`","normalize","`","is","True",".","Defaults","to","2","*","pi",".","eps","(","float",",","optional",")",":","A","value","added","to","the","denominator","for","numerical","stability",".","Defaults","to","1e-6",".","offset","(","float",")",":","offset","add","to","embed","when","do","the","normalization",".","Defaults","to","0.","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None"]
code: def __init__(
      self,
      num_feats: int,
      temperature: int = 10000,
      normalize: bool = False,
      scale: float = 2 * math.pi,
      eps: float = 1e-6,
      offset: float = 0.0,
      init_cfg: OptMultiConfig = None,
  ) -> None:
      super().__init__(init_cfg=init_cfg)
      if normalize:
          assert isinstance(scale, (float, int)), (
              "when normalize is set,"
              "scale should be provided and in float or int type, "
              f"found {type(scale)}"
          )
      self.num_feats = num_feats
      self.temperature = temperature
      self.normalize = normalize
      self.scale = scale
      self.eps = eps
      self.offset = offset
  
imports: import math
  from typing import Optional
  import torch
  import torch.nn
  from mmengine.model import BaseModule
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import MultiConfig, OptMultiConfig
label_desc: Use image node_id 1 to create a new SinePositionalEncoding object from inherited base classes: BaseModule with example: obj = SinePositionalEncoding(num_feats, temperature, normalize, scale, eps, offset, init_cfg)