class_docstr: Extract global information through double pyramid pool structure and attention calculation by transformer block.
  
  Args:
      stride(int): The stride for the inputs.
      input_channel(int): The total channels of input features.
      mid_channel(int, optional): The output channels of the first pyramid pool. Default: 256.
      out_channel(int, optional): The output channels. Default: 512.
      len_trans(int, optional): The depth of transformer block. Default: 1.
      bin_sizes(list, optional): The output size of the second pyramid pool. Default: (2, 4, 6).
      mlp_ratios(int, optional): The expandsion ratio of the mlp. Default: 2.
      attn_ratio(int, optional): The expandsion ratio of the attention. Default: 2.
      merge_type(str, optional): The merge type of the output of the second pyramid pool, which should be one of (`concat`, `add`). Default: 'concat'.
      align_corners(bool, optional): Whether to use `align_corners` when interpolating. Default: False.
class_docstr_tok: ["Extract","global","information","through","double","pyramid","pool","structure","and","attention","calculation","by","transformer","block",".","Args",":","stride","(","int",")",":","The","stride","for","the","inputs",".","input_channel","(","int",")",":","The","total","channels","of","input","features",".","mid_channel","(","int",",","optional",")",":","The","output","channels","of","the","first","pyramid","pool",".","Default",":","256.","out_channel","(","int",",","optional",")",":","The","output","channels",".","Default",":","512.","len_trans","(","int",",","optional",")",":","The","depth","of","transformer","block",".","Default",":","1.","bin_sizes","(","list",",","optional",")",":","The","output","size","of","the","second","pyramid","pool",".","Default",":","(","2",",","4",",","6",")",".","mlp_ratios","(","int",",","optional",")",":","The","expandsion","ratio","of","the","mlp",".","Default",":","2.","attn_ratio","(","int",",","optional",")",":","The","expandsion","ratio","of","the","attention",".","Default",":","2.","merge_type","(","str",",","optional",")",":","The","merge","type","of","the","output","of","the","second","pyramid","pool",",","which","should","be","one","of","(","`","concat","`",",","`","add","`",")",".","Default",":","'concat","'",".","align_corners","(","bool",",","optional",")",":","Whether","to","use","`","align_corners","`","when","interpolating",".","Default",":","False","."]
code: def __init__(
      self,
      stride,
      input_channel,
      mid_channel=256,
      output_channel=512,
      len_trans=1,
      bin_sizes=(2, 4, 6),
      mlp_ratios=2,
      attn_ratio=2,
      merge_type="concat",
      align_corners=False,
  ):
      super().__init__()
  
      self.mid_channel = mid_channel
      self.align_corners = align_corners
      self.mlp_rations = mlp_ratios
      self.attn_ratio = attn_ratio
      if isinstance(len_trans, int):
          self.len_trans = [len_trans] * len(bin_sizes)
      elif isinstance(len_trans, (list, tuple)):
          self.len_trans = len_trans
          if len(len_trans) != len(bin_sizes):
              raise ValueError(
                  "If len_trans is list or tuple, the length should be same as bin_sizes"
              )
      else:
          raise ValueError(
              "`len_trans` only support int, list and tuple type"
          )
  
      if merge_type not in ["add", "concat"]:
          raise ("`merge_type only support `add` or `concat`.")
      self.merge_type = merge_type
  
      self.pp1 = PyramidPoolAgg(stride=stride)
      self.conv_mid = layers.ConvBN(input_channel, mid_channel, 1)
      self.pp2 = nn.LayerList(
          [
              self._make_stage(
                  embdeding_channels=mid_channel,
                  size=size,
                  block_num=block_num,
              )
              for size, block_num in zip(bin_sizes, self.len_trans)
          ]
      )
  
      if self.merge_type == "concat":
          in_chan = mid_channel + mid_channel * len(bin_sizes)
      else:
          in_chan = mid_channel
      self.conv_out = layers.ConvBNReLU(
          in_chan, output_channel, kernel_size=1
      )
  
imports: from functools import partial
  from collections import defaultdict
  import paddle
  import paddle.nn
  import paddle.nn.functional
  import paddleseg
  from paddleseg import utils
  from paddleseg.models import layers
  from paddleseg.cvlibs import manager
  from paddleseg.models.backbones.transformer_utils import Identity, DropPath
  from ppmatting.models.layers import MLFF
  from ppmatting.models.losses import MRSD, GradientLoss
label_desc: Use image node_id 1 to create a new DoublePyramidPoolModule object from inherited base classes: nn with example: obj = DoublePyramidPoolModule(stride, input_channel, mid_channel, output_channel, len_trans, bin_sizes, mlp_ratios, attn_ratio, merge_type, align_corners)