docstr: Forward the backbone model and then the base model, supported by the backbone feature maps.
  Return model predictions.
  
  Parameters
  ----------
  image : torch.Tensor
      Input RGB image.
  mask : torch.Tensor
      Binary mask of the foreground region.
  
  Returns
  -------
  torch.Tensor
      Harmonized RGB image.
docstr_tok: ["Forward","the","backbone","model","and","then","the","base","model",",","supported","by","the","backbone","feature","maps",".","Return","model","predictions",".","Parameters","--","--","--","--","--","image",":","torch.Tensor","Input","RGB","image",".","mask",":","torch.Tensor","Binary","mask","of","the","foreground","region",".","Returns","--","--","--","-","torch.Tensor","Harmonized","RGB","image","."]
code: def forward(self, image, mask):
      """
      Forward the backbone model and then the base model, supported by the backbone feature maps.
      Return model predictions.
  
      Parameters
      ----------
      image : torch.Tensor
          Input RGB image.
      mask : torch.Tensor
          Binary mask of the foreground region.
  
      Returns
      -------
      torch.Tensor
          Harmonized RGB image.
      """
      backbone_image = image
      backbone_mask = torch.cat((mask, 1.0 - mask), dim=1)
      if self.downsize_backbone_input:
          backbone_image = nn.functional.interpolate(
              backbone_image,
              scale_factor=0.5,
              mode="bilinear",
              align_corners=True,
          )
          backbone_mask = nn.functional.interpolate(
              backbone_mask,
              backbone_image.size()[2:],
              mode="bilinear",
              align_corners=True,
          )
      backbone_image = (
          self.fusion(backbone_image, backbone_mask[:, :1])
          if self.mask_fusion == "rgb"
          else backbone_image
      )
      backbone_mask_features = (
          self.mask_conv(backbone_mask[:, :1])
          if self.mask_fusion == "sum"
          else None
      )
      backbone_features = self.backbone(
          backbone_image, backbone_mask, backbone_mask_features
      )
  
      output = self.model(image, mask, backbone_features)
      return output
  
file_path: carefree-learn/cflearn/api/cv/third_party/iharm/model/backboned/ih_model.py
imports: import torch
  import torch.nn
  from ..ops import ScaleLayer
  from ..ops import SimpleInputFusion
label_desc: Use image node_id 2 for calling the IHModelWithBackbone obj's underlying member method code with example usage: obj.forward(image, mask) and returns: output