def METHOD_NAME(self, prediction: dict[str, torch.Tensor], target: dict[str, torch.Tensor]) -> torch.Tensor:
    """
    Args:
        prediction: dictionary of predicted outputs for three branches,
            each of which should have the shape of BNHW.
        target: dictionary of ground truths for three branches,
            each of which should have the shape of BNHW.
    """
    if not (HoVerNetBranch.NP.value in prediction and HoVerNetBranch.HV.value in prediction):
        raise ValueError(
            "nucleus prediction (NP) and horizontal_vertical (HV) branches must be "
            "present for prediction and target parameters"
        )
    if not (HoVerNetBranch.NP.value in target and HoVerNetBranch.HV.value in target):
        raise ValueError(
            "nucleus prediction (NP) and horizontal_vertical (HV) branches must be "
            "present for prediction and target parameters"
        )
    if HoVerNetBranch.NC.value not in target and HoVerNetBranch.NC.value in target:
        raise ValueError(
            "type_prediction (NC) must be present in both or neither of the prediction and target parameters"
        )
    if HoVerNetBranch.NC.value in target and HoVerNetBranch.NC.value not in target:
        raise ValueError(
            "type_prediction (NC) must be present in both or neither of the prediction and target parameters"
        )
    # Compute the NP branch loss
    dice_loss_np = (
        self.dice(prediction[HoVerNetBranch.NP.value], target[HoVerNetBranch.NP.value]) * self.lambda_np_dice
    )
    # convert to target class indices
    argmax_target = target[HoVerNetBranch.NP.value].argmax(dim=1)
    ce_loss_np = self.ce(prediction[HoVerNetBranch.NP.value], argmax_target) * self.lambda_np_ce
    loss_np = dice_loss_np + ce_loss_np
    # Compute the HV branch loss
    loss_hv_mse = (
        F.mse_loss(prediction[HoVerNetBranch.HV.value], target[HoVerNetBranch.HV.value]) * self.lambda_hv_mse
    )
    # Use the nuclei class, one hot encoded, as the mask
    loss_hv_mse_grad = (
        self._mse_gradient_loss(
            prediction[HoVerNetBranch.HV.value],
            target[HoVerNetBranch.HV.value],
            target[HoVerNetBranch.NP.value][:, 1],
        )
        * self.lambda_hv_mse_grad
    )
    loss_hv = loss_hv_mse_grad + loss_hv_mse
    # Compute the NC branch loss
    loss_nc = 0
    if HoVerNetBranch.NC.value in prediction:
        dice_loss_nc = (
            self.dice(prediction[HoVerNetBranch.NC.value], target[HoVerNetBranch.NC.value]) * self.lambda_nc_dice
        )
        # Convert to target class indices
        argmax_target = target[HoVerNetBranch.NC.value].argmax(dim=1)
        ce_loss_nc = self.ce(prediction[HoVerNetBranch.NC.value], argmax_target) * self.lambda_nc_ce
        loss_nc = dice_loss_nc + ce_loss_nc
    # Sum the losses from each branch
    loss: torch.Tensor = loss_hv + loss_np + loss_nc
    return loss