class_docstr: An attention module used in PETR. `End-to-End Multi-Person
  Pose Estimation with Transformers`.
  
  Args:
      embed_dims (int): The embedding dimension of Attention.
          Default: 256.
      num_heads (int): Parallel attention heads. Default: 8.
      num_levels (int): The number of feature map used in
          Attention. Default: 4.
      num_points (int): The number of sampling points for
          each query in each head. Default: 17.
      im2col_step (int): The step used in image_to_column.
          Default: 64.
      dropout (float): A Dropout layer on `inp_residual`.
          Default: 0.1.
      init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
          Default: None.
class_docstr_tok: ["An","attention","module","used","in","PETR",".","`","End-to-End","Multi-Person","Pose","Estimation","with","Transformers","`",".","Args",":","embed_dims","(","int",")",":","The","embedding","dimension","of","Attention",".","Default",":","256.","num_heads","(","int",")",":","Parallel","attention","heads",".","Default",":","8.","num_levels","(","int",")",":","The","number","of","feature","map","used","in","Attention",".","Default",":","4.","num_points","(","int",")",":","The","number","of","sampling","points","for","each","query","in","each","head",".","Default",":","17.","im2col_step","(","int",")",":","The","step","used","in","image_to_column",".","Default",":","64.","dropout","(","float",")",":","A","Dropout","layer","on","`","inp_residual","`",".","Default",":","0.1.","init_cfg","(","obj",":","`","mmcv.ConfigDict","`",")",":","The","Config","for","initialization",".","Default",":","None","."]
code: def __init__(
      self,
      embed_dims=256,
      num_heads=8,
      num_levels=4,
      num_points=17,
      im2col_step=64,
      dropout=0.1,
      norm_cfg=None,
      init_cfg=None,
      batch_first=False,
      lr_mult=0.1,
  ):
      super().__init__()
      if embed_dims % num_heads != 0:
          raise ValueError(
              f"embed_dims must be divisible by num_heads, "
              f"but got {embed_dims} and {num_heads}"
          )
      dim_per_head = embed_dims // num_heads
      self.norm_cfg = norm_cfg
      self.init_cfg = init_cfg
      self.dropout = nn.Dropout(dropout)
      self.batch_first = batch_first
  
      # you'd better set dim_per_head to a power of 2
      # which is more efficient in the CUDA implementation
      def _is_power_of_2(n):
          if (not isinstance(n, int)) or (n < 0):
              raise ValueError(
                  "invalid input for _is_power_of_2: {} (type: {})".format(
                      n, type(n)
                  )
              )
          return (n & (n - 1) == 0) and n != 0
  
      if not _is_power_of_2(dim_per_head):
          warnings.warn(
              "You'd better set embed_dims in "
              "MultiScaleDeformAttention to make "
              "the dimension of each attention head a power of 2 "
              "which is more efficient in our CUDA implementation."
          )
  
      self.im2col_step = im2col_step
      self.embed_dims = embed_dims
      self.num_levels = num_levels
      self.num_heads = num_heads
      self.num_points = num_points
      self.sampling_offsets = nn.Linear(
          embed_dims,
          num_heads * num_levels * num_points * 2,
          weight_attr=ParamAttr(learning_rate=lr_mult),
          bias_attr=ParamAttr(learning_rate=lr_mult),
      )
      self.attention_weights = nn.Linear(
          embed_dims, num_heads * num_levels * num_points
      )
      self.value_proj = nn.Linear(embed_dims, embed_dims)
      self.output_proj = nn.Linear(embed_dims, embed_dims)
  
      try:
          # use cuda op
          from deformable_detr_ops import ms_deformable_attn
      except:
          # use paddle func
          from .utils import (
              deformable_attention_core_func as ms_deformable_attn,
          )
      self.ms_deformable_attn_core = ms_deformable_attn
  
      self.init_weights()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle import ParamAttr
  from ppdet.core.workspace import register
  from ..layers import MultiHeadAttention, _convert_attention_mask
  from .utils import _get_clones
  from ..initializer import linear_init_, normal_, constant_, xavier_uniform_
label_desc: Use image node_id 1 to create a new MultiScaleDeformablePoseAttention object from inherited base classes: nn with example: obj = MultiScaleDeformablePoseAttention(embed_dims, num_heads, num_levels, num_points, im2col_step, dropout, norm_cfg, init_cfg, batch_first, lr_mult)