class_docstr: Implements the DeformableDETR transformer.
  
  Args:
      as_two_stage (bool): Generate query from encoder features.
          Default: False.
      num_feature_levels (int): Number of feature maps from FPN:
          Default: 4.
      two_stage_num_proposals (int): Number of proposals when set
          `as_two_stage` as True. Default: 300.
class_docstr_tok: ["Implements","the","DeformableDETR","transformer",".","Args",":","as_two_stage","(","bool",")",":","Generate","query","from","encoder","features",".","Default",":","False",".","num_feature_levels","(","int",")",":","Number","of","feature","maps","from","FPN",":","Default",":","4.","two_stage_num_proposals","(","int",")",":","Number","of","proposals","when","set","`","as_two_stage","`","as","True",".","Default",":","300","."]
docstr: Get the valid radios of feature maps of all  level.
code: def get_valid_ratio(self, mask):
      """Get the valid radios of feature maps of all  level."""
      _, H, W = mask.shape
      valid_H = torch.sum(~mask[:, :, 0], 1)
      valid_W = torch.sum(~mask[:, 0, :], 1)
      valid_ratio_h = valid_H.float() / H
      valid_ratio_w = valid_W.float() / W
      valid_ratio = torch.stack([valid_ratio_w, valid_ratio_h], -1)
      return valid_ratio
  
imports: import math
  import warnings
  import torch
  import torch.nn
  from mmcv.cnn import build_norm_layer
  from mmcv.cnn.bricks.transformer import BaseTransformerLayer, TransformerLayerSequence, build_transformer_layer_sequence
  from mmcv.ops import MultiScaleDeformableAttention
  from mmengine.model import BaseModule
  from mmengine.model.weight_init import xavier_init
  from torch.nn.init import normal_
  from mmdet.models.layers.transformer import inverse_sigmoid
  from mmdet.registry import MODELS
label_desc: Use image node_id 6 for calling the DeformableDetrTransformer obj's underlying member method code with example usage: obj.get_valid_ratio(mask) and returns: valid_ratio