class_docstr: Loss function for HoVerNet pipeline, which is combination of losses across the three branches.
  The NP (nucleus prediction) branch uses Dice + CrossEntropy.
  The HV (Horizontal and Vertical) distance from centroid branch uses MSE + MSE of the gradient.
  The NC (Nuclear Class prediction) branch uses Dice + CrossEntropy
  The result is a weighted sum of these losses.
  
  Args:
      lambda_hv_mse: Weight factor to apply to the HV regression MSE part of the overall loss
      lambda_hv_mse_grad: Weight factor to apply to the MSE of the HV gradient part of the overall loss
      lambda_np_ce: Weight factor to apply to the nuclei prediction CrossEntropyLoss part
          of the overall loss
      lambda_np_dice: Weight factor to apply to the nuclei prediction DiceLoss part of overall loss
      lambda_nc_ce: Weight factor to apply to the nuclei class prediction CrossEntropyLoss part
          of the overall loss
      lambda_nc_dice: Weight factor to apply to the nuclei class prediction DiceLoss part of the
          overall loss
docstr: Compute the MSE loss of the gradients of the horizontal and vertical centroid distance maps
docstr_tok: ["Compute","the","MSE","loss","of","the","gradients","of","the","horizontal","and","vertical","centroid","distance","maps"]
code: def _mse_gradient_loss(
      self,
      prediction: torch.Tensor,
      target: torch.Tensor,
      focus: torch.Tensor,
  ) -> torch.Tensor:
      """Compute the MSE loss of the gradients of the horizontal and vertical centroid distance maps"""
  
      pred_grad = self._compute_sobel(prediction)
      true_grad = self._compute_sobel(target)
  
      loss = pred_grad - true_grad
  
      # The focus constrains the loss computation to the detected nuclear regions
      # (i.e. background is excluded)
      focus = focus[:, None, ...]
      focus = torch.cat((focus, focus), 1)
  
      loss = focus * (loss * loss)
      loss = loss.sum() / (focus.sum() + 1.0e-8)
  
      return loss
  
file_path: MONAI/monai/apps/pathology/losses/hovernet_loss.py
imports: from __future__ import annotations
  import torch
  from torch.nn import CrossEntropyLoss
  from torch.nn import functional
  from torch.nn.modules.loss import _Loss
  from monai.losses import DiceLoss
  from monai.transforms import SobelGradients
  from monai.utils.enums import HoVerNetBranch
label_desc: Use image node_id 3 for calling the HoVerNetLoss obj's underlying member method code with example usage: obj._mse_gradient_loss(prediction, target, focus) and returns: loss