class_docstr: Implements the Region Mutual Information(RMI) Loss（https://arxiv.org/abs/1910.12037） for Semantic Segmentation.
  Unlike vanilla rmi loss which contains Cross Entropy Loss, we disband them and only
  left the RMI-related parts.
  The motivation is to allow for a more flexible combination of losses during training.
  For example, by employing mixed loss to merge RMI Loss with Boostrap Cross Entropy Loss,
  we can achieve the online mining of hard examples together with attention to region information.
  Args:
      weight (tuple|list|ndarray|Tensor, optional): A manual rescaling weight
          given to each class. Its length must be equal to the number of classes.
          Default ``None``.
      ignore_index (int64, optional): Specifies a target value that is ignored
          and does not contribute to the input gradient. Default ``255``.
code: def __init__(
      self,
      num_classes=19,
      rmi_radius=3,
      rmi_pool_way=0,
      rmi_pool_size=3,
      rmi_pool_stride=3,
      loss_weight_lambda=0.5,
      ignore_index=255,
  ):
      super(RMILoss, self).__init__()
  
      self.num_classes = num_classes
      assert rmi_radius in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      self.rmi_radius = rmi_radius
      assert rmi_pool_way in [0, 1, 2, 3]
      self.rmi_pool_way = rmi_pool_way
      assert rmi_pool_size == rmi_pool_stride
      self.rmi_pool_size = rmi_pool_size
      self.rmi_pool_stride = rmi_pool_stride
      self.weight_lambda = loss_weight_lambda
      self.half_d = self.rmi_radius * self.rmi_radius
      self.d = 2 * self.half_d
      self.kernel_padding = self.rmi_pool_size // 2
      self.ignore_index = ignore_index
  
file_path: PaddleSeg/paddleseg/models/losses/rmi_loss.py
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager
label_desc: Use image node_id 1 to create a new RMILoss object from inherited base classes: nn with example: obj = RMILoss(num_classes, rmi_radius, rmi_pool_way, rmi_pool_size, rmi_pool_stride, loss_weight_lambda, ignore_index)