class_docstr: The PPMattingV2 implementation based on PaddlePaddle.
  
  The original article refers to
  TODO Guowei Chen, et, al. "" ().
  
  Args:
      backbone: backobne model.
      pretrained(str, optional): The path of pretrianed model. Defautl: None.
      dpp_len_trans(int, optional): The depth of transformer block in dpp(DoublePyramidPoolModule). Default: 1.
      dpp_index(list, optional): The index of backone output which as the input in dpp. Default: [1, 2, 3, 4].
      dpp_mid_channel(int, optional): The output channels of the first pyramid pool in dpp. Default: 256.
      dpp_out_channel(int, optional): The output channels of dpp. Default: 512.
      dpp_bin_sizes(list, optional): The output size of the second pyramid pool in dpp. Default: (2, 4, 6).
      dpp_mlp_ratios(int, optional): The expandsion ratio of mlp in dpp. Default: 2.
      dpp_attn_ratio(int, optional): The expandsion ratio of attention. Default: 2.
      dpp_merge_type(str, optional): The merge type of the output of the second pyramid pool in dpp, 
          which should be one of (`concat`, `add`). Default: 'concat'.
      mlff_merge_type(str, optional): The merge type of the multi features before output. 
          It should be one of ('add', 'concat'). Default: 'concat'.
class_docstr_tok: ["The","PPMattingV2","implementation","based","on","PaddlePaddle",".","The","original","article","refers","to","TODO","Guowei","Chen",",","et",",","al.","``","''","(",")",".","Args",":","backbone",":","backobne","model",".","pretrained","(","str",",","optional",")",":","The","path","of","pretrianed","model",".","Defautl",":","None",".","dpp_len_trans","(","int",",","optional",")",":","The","depth","of","transformer","block","in","dpp","(","DoublePyramidPoolModule",")",".","Default",":","1.","dpp_index","(","list",",","optional",")",":","The","index","of","backone","output","which","as","the","input","in","dpp",".","Default",":","[","1",",","2",",","3",",","4","]",".","dpp_mid_channel","(","int",",","optional",")",":","The","output","channels","of","the","first","pyramid","pool","in","dpp",".","Default",":","256.","dpp_out_channel","(","int",",","optional",")",":","The","output","channels","of","dpp",".","Default",":","512.","dpp_bin_sizes","(","list",",","optional",")",":","The","output","size","of","the","second","pyramid","pool","in","dpp",".","Default",":","(","2",",","4",",","6",")",".","dpp_mlp_ratios","(","int",",","optional",")",":","The","expandsion","ratio","of","mlp","in","dpp",".","Default",":","2.","dpp_attn_ratio","(","int",",","optional",")",":","The","expandsion","ratio","of","attention",".","Default",":","2.","dpp_merge_type","(","str",",","optional",")",":","The","merge","type","of","the","output","of","the","second","pyramid","pool","in","dpp",",","which","should","be","one","of","(","`","concat","`",",","`","add","`",")",".","Default",":","'concat","'",".","mlff_merge_type","(","str",",","optional",")",":","The","merge","type","of","the","multi","features","before","output",".","It","should","be","one","of","(","'add","'",",","'concat","'",")",".","Default",":","'concat","'","."]
code: def __init__(
      self,
      backbone,
      pretrained=None,
      dpp_len_trans=1,
      dpp_index=[1, 2, 3, 4],
      dpp_mid_channel=256,
      dpp_output_channel=512,
      dpp_bin_sizes=(2, 4, 6),
      dpp_mlp_ratios=2,
      dpp_attn_ratio=2,
      dpp_merge_type="concat",
      mlff_merge_type="concat",
      decoder_channels=[128, 96, 64, 32, 32],
      head_channel=32,
  ):
      super().__init__()
  
      self.backbone = backbone
      self.backbone_channels = backbone.feat_channels
  
      # check
      assert (
          len(backbone.feat_channels) == 5
      ), "Backbone should return 5 features with different scales"
      assert max(dpp_index) < len(
          backbone.feat_channels
      ), "The element of `dpp_index` should be less than the number of return features of backbone."
  
      # dpp module
      self.dpp_index = dpp_index
      self.dpp = DoublePyramidPoolModule(
          stride=2,
          input_channel=sum(
              self.backbone_channels[i] for i in self.dpp_index
          ),
          mid_channel=dpp_mid_channel,
          output_channel=dpp_output_channel,
          len_trans=dpp_len_trans,
          bin_sizes=dpp_bin_sizes,
          mlp_ratios=dpp_mlp_ratios,
          attn_ratio=dpp_attn_ratio,
          merge_type=dpp_merge_type,
      )
  
      # decoder
      self.mlff32x = MLFF(
          in_channels=[self.backbone_channels[-1], dpp_output_channel],
          mid_channels=[dpp_output_channel, dpp_output_channel],
          out_channel=decoder_channels[0],
          merge_type=mlff_merge_type,
      )
      self.mlff16x = MLFF(
          in_channels=[
              self.backbone_channels[-2],
              decoder_channels[0],
              dpp_output_channel,
          ],
          mid_channels=[
              decoder_channels[0],
              decoder_channels[0],
              decoder_channels[0],
          ],
          out_channel=decoder_channels[1],
          merge_type=mlff_merge_type,
      )
      self.mlff8x = MLFF(
          in_channels=[
              self.backbone_channels[-3],
              decoder_channels[1],
              dpp_output_channel,
          ],
          mid_channels=[
              decoder_channels[1],
              decoder_channels[1],
              decoder_channels[1],
          ],
          out_channel=decoder_channels[2],
          merge_type=mlff_merge_type,
      )
      self.mlff4x = MLFF(
          in_channels=[
              self.backbone_channels[-4],
              decoder_channels[2],
              3,
          ],
          mid_channels=[decoder_channels[2], decoder_channels[2], 3],
          out_channel=decoder_channels[3],
      )
      self.mlff2x = MLFF(
          in_channels=[
              self.backbone_channels[-5],
              decoder_channels[3],
              3,
          ],
          mid_channels=[decoder_channels[3], decoder_channels[3], 3],
          out_channel=decoder_channels[4],
      )
  
      self.matting_head_mlff8x = MattingHead(
          in_chan=decoder_channels[2], mid_chan=32
      )
      self.matting_head_mlff2x = MattingHead(
          in_chan=decoder_channels[4] + 3,
          mid_chan=head_channel,
          mid_num=2,
      )
  
      # loss
      self.loss_func_dict = None
  
      # pretrained
      self.pretrained = pretrained
      self.init_weight()
  
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 PPMattingV2 object from inherited base classes: nn with example: obj = PPMattingV2(backbone, pretrained, dpp_len_trans, dpp_index, dpp_mid_channel, dpp_output_channel, dpp_bin_sizes, dpp_mlp_ratios, dpp_attn_ratio, dpp_merge_type, mlff_merge_type, decoder_channels, head_channel)