class_docstr: Implementation of reparameterizable conditional positional encoding.
  For more details refer to paper:
  `Conditional Positional Encodings for Vision Transformers <https://arxiv.org/pdf/2102.10882.pdf>`_
  
  Args:
      opts: Command line arguments.
      in_channels: Number of input channels.
      embed_dim: Number of embedding dimensions. Default: 768
      spatial_shape: Spatial shape of kernel for positional encoding. Default: (7, 7)
      inference_mode: Flag to instantiate block in inference mode. Default: ``False``
class_docstr_tok: ["Implementation","of","reparameterizable","conditional","positional","encoding",".","For","more","details","refer","to","paper",":","`","Conditional","Positional","Encodings","for","Vision","Transformers","<","https",":","\/\/arxiv.org\/pdf\/2102.10882.pdf",">","`","_","Args",":","opts",":","Command","line","arguments",".","in_channels",":","Number","of","input","channels",".","embed_dim",":","Number","of","embedding","dimensions",".","Default",":","768","spatial_shape",":","Spatial","shape","of","kernel","for","positional","encoding",".","Default",":","(","7",",","7",")","inference_mode",":","Flag","to","instantiate","block","in","inference","mode",".","Default",":","``","False","``"]
code: def __init__(
      self,
      opts: argparse.Namespace,
      in_channels: int,
      embed_dim: int = 768,
      spatial_shape: Union[int, Tuple[int, int]] = (7, 7),
      inference_mode: bool = False,
  ):
      super(RepCPE, self).__init__()
      if isinstance(spatial_shape, int):
          spatial_shape = tuple([spatial_shape] * 2)
      assert isinstance(spatial_shape, Tuple), (
          f'"spatial_shape" must by a sequence or int, '
          f"get {type(spatial_shape)} instead."
      )
      assert len(spatial_shape) == 2, (
          f'Length of "spatial_shape" should be 2, '
          f"got {len(spatial_shape)} instead."
      )
  
      self.spatial_shape = spatial_shape
      self.embed_dim = embed_dim
      self.in_channels = in_channels
      self.groups = embed_dim
  
      if inference_mode:
          self.reparam_conv = nn.Conv2d(
              in_channels=self.in_channels,
              out_channels=self.embed_dim,
              kernel_size=self.spatial_shape,
              stride=1,
              padding=int(self.spatial_shape[0] // 2),
              groups=self.embed_dim,
              bias=True,
          )
      else:
          self.pe = ConvLayer2d(
              opts,
              in_channels=in_channels,
              out_channels=embed_dim,
              kernel_size=spatial_shape,
              stride=1,
              padding=int(spatial_shape[0] // 2),
              use_norm=False,
              use_act=False,
              bias=True,
              groups=embed_dim,
          )
  
imports: import argparse
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  from cvnets.layers import ConvLayer2d, MultiHeadAttention, StochasticDepth
  from cvnets.layers.normalization.batch_norm import BatchNorm2d
  from cvnets.modules import BaseModule
  from cvnets.modules.mobileone_block import MobileOneBlock, RepLKBlock
label_desc: Use image node_id 1 to create a new RepCPE object from inherited base classes: BaseModule with example: obj = RepCPE(opts, in_channels, embed_dim, spatial_shape, inference_mode)