class_docstr: SparsercnnHead
  Args:
      roi_input_shape (list[ShapeSpec]): The output shape of fpn
      num_classes (int): Number of classes,
      head_hidden_dim (int): The param of MultiHeadAttention,
      head_dim_feedforward (int): The param of MultiHeadAttention,
      nhead (int): The param of MultiHeadAttention,
      head_dropout (float): The p of dropout,
      head_cls (int): The number of class head,
      head_reg (int): The number of regressionhead,
      head_num_dynamic (int): The number of DynamicConv's param,
      head_num_heads (int): The number of RCNNHead,
      deep_supervision (int): wheather supervise the intermediate results,
      num_proposals (int): the number of proposals boxes and features
class_docstr_tok: ["SparsercnnHead","Args",":","roi_input_shape","(","list","[","ShapeSpec","]",")",":","The","output","shape","of","fpn","num_classes","(","int",")",":","Number","of","classes",",","head_hidden_dim","(","int",")",":","The","param","of","MultiHeadAttention",",","head_dim_feedforward","(","int",")",":","The","param","of","MultiHeadAttention",",","nhead","(","int",")",":","The","param","of","MultiHeadAttention",",","head_dropout","(","float",")",":","The","p","of","dropout",",","head_cls","(","int",")",":","The","number","of","class","head",",","head_reg","(","int",")",":","The","number","of","regressionhead",",","head_num_dynamic","(","int",")",":","The","number","of","DynamicConv","'s","param",",","head_num_heads","(","int",")",":","The","number","of","RCNNHead",",","deep_supervision","(","int",")",":","wheather","supervise","the","intermediate","results",",","num_proposals","(","int",")",":","the","number","of","proposals","boxes","and","features"]
code: def _init_box_pooler(input_shape):
      pooler_resolution = 7
      sampling_ratio = 2
  
      if input_shape is not None:
          pooler_scales = tuple(
              1.0 / input_shape[k].stride
              for k in range(len(input_shape))
          )
          in_channels = [
              input_shape[f].channels for f in range(len(input_shape))
          ]
          end_level = len(input_shape) - 1
          # Check all channel counts are equal
          assert len(set(in_channels)) == 1, in_channels
      else:
          pooler_scales = [1.0 / 4.0, 1.0 / 8.0, 1.0 / 16.0, 1.0 / 32.0]
          end_level = 3
  
      aligned = True
      if paddle.device.is_compiled_with_custom_device("npu"):
          aligned = False
      box_pooler = RoIAlign(
          resolution=pooler_resolution,
          spatial_scale=pooler_scales,
          sampling_ratio=sampling_ratio,
          end_level=end_level,
          aligned=aligned,
      )
      return box_pooler
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import copy
  import paddle
  import paddle.nn
  from ppdet.core.workspace import register
  from ppdet.modeling.heads.roi_extractor import RoIAlign
  from ppdet.modeling.bbox_utils import delta2bbox
  from ..None import initializer
label_desc: Use image node_id 3 for calling the SparseRCNNHead obj's underlying member method code with example usage: obj._init_box_pooler(input_shape) and returns: box_pooler