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 loss(self, logit_dict, label_dict, loss_func_dict=None):
      if loss_func_dict is None:
          if self.loss_func_dict is None:
              self.loss_func_dict = defaultdict(list)
              self.loss_func_dict["alpha"].append(MRSD())
              self.loss_func_dict["alpha"].append(GradientLoss())
              self.loss_func_dict["alpha_8x"].append(MRSD())
              self.loss_func_dict["alpha_8x"].append(GradientLoss())
      else:
          self.loss_func_dict = loss_func_dict
  
      loss = {}
      alpha_8x_label = F.interpolate(
          label_dict["alpha"],
          size=logit_dict["alpha_8x"].shape[-2:],
          mode="area",
          align_corners=False,
      )
      loss["alpha_8x_mrsd"] = self.loss_func_dict["alpha_8x"][0](
          logit_dict["alpha_8x"], alpha_8x_label
      )
      loss["alpha_8x_grad"] = self.loss_func_dict["alpha_8x"][1](
          logit_dict["alpha_8x"], alpha_8x_label
      )
      loss["alpha_8x"] = loss["alpha_8x_mrsd"] + loss["alpha_8x_grad"]
  
      transition_mask = label_dict["trimap"] == 128
      loss["alpha_mrsd"] = self.loss_func_dict["alpha"][0](
          logit_dict["alpha"], label_dict["alpha"]
      ) + 2 * self.loss_func_dict["alpha"][0](
          logit_dict["alpha"], label_dict["alpha"], transition_mask
      )
      loss["alpha_grad"] = self.loss_func_dict["alpha"][1](
          logit_dict["alpha"], label_dict["alpha"]
      ) + 2 * self.loss_func_dict["alpha"][1](
          logit_dict["alpha"], label_dict["alpha"], transition_mask
      )
      loss["alpha"] = loss["alpha_mrsd"] + loss["alpha_grad"]
  
      loss["all"] = loss["alpha"] + loss["alpha_8x"]
      return loss
  
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 3 for calling the PPMattingV2 obj's underlying member method code with example usage: obj.loss(logit_dict, label_dict, loss_func_dict) and returns: loss