class_docstr: Implements the ohem cross entropy loss function.
  
  Args:
      border (int, optional): The value of border to relax. Default: 1.
      calculate_weights (bool, optional): Whether to calculate weights for every classes. Default: False.
      upper_bound (float, optional): The upper bound of weights if calculating weights for every classes. Default: 1.0.
      ignore_index (int64): Specifies a target value that is ignored
          and does not contribute to the input gradient. Default: 255.
class_docstr_tok: ["Implements","the","ohem","cross","entropy","loss","function",".","Args",":","border","(","int",",","optional",")",":","The","value","of","border","to","relax",".","Default",":","1.","calculate_weights","(","bool",",","optional",")",":","Whether","to","calculate","weights","for","every","classes",".","Default",":","False",".","upper_bound","(","float",",","optional",")",":","The","upper","bound","of","weights","if","calculating","weights","for","every","classes",".","Default",":","1.0.","ignore_index","(","int64",")",":","Specifies","a","target","value","that","is","ignored","and","does","not","contribute","to","the","input","gradient",".","Default",":","255","."]
docstr: Forward computation.
  
  Args:
      logit (Tensor): Logit tensor, the data type is float32, float64. Shape is
          (N, C), where C is number of classes, and if shape is more than 2D, this
          is (N, C, D1, D2,..., Dk), k >= 1.
      label (Tensor): Label tensor, the data type is int64. Shape is (N), where each
          value is 0 <= label[i] <= C-1, and if shape is more than 2D, this is
          (N, D1, D2,..., Dk), k >= 1.
docstr_tok: ["Forward","computation",".","Args",":","logit","(","Tensor",")",":","Logit","tensor",",","the","data","type","is","float32",",","float64",".","Shape","is","(","N",",","C",")",",","where","C","is","number","of","classes",",","and","if","shape","is","more","than","2D",",","this","is","(","N",",","C",",","D1",",","D2",",","...",",","Dk",")",",","k",">","=","1.","label","(","Tensor",")",":","Label","tensor",",","the","data","type","is","int64",".","Shape","is","(","N",")",",","where","each","value","is","0","<","=","label","[","i","]","<","=","C-1",",","and","if","shape","is","more","than","2D",",","this","is","(","N",",","D1",",","D2",",","...",",","Dk",")",",","k",">","=","1","."]
code: def forward(self, logit, label):
      """
      Forward computation.
  
      Args:
          logit (Tensor): Logit tensor, the data type is float32, float64. Shape is
              (N, C), where C is number of classes, and if shape is more than 2D, this
              is (N, C, D1, D2,..., Dk), k >= 1.
          label (Tensor): Label tensor, the data type is int64. Shape is (N), where each
              value is 0 <= label[i] <= C-1, and if shape is more than 2D, this is
              (N, D1, D2,..., Dk), k >= 1.
      """
      n, c, h, w = logit.shape
      label.stop_gradient = True
      label = self.relax_onehot(label, c)
      weights = label[:, :-1, :, :].sum(1).astype("float32")
      ignore_mask = (weights == 0).astype("float32")
      # border is greater than 1, other is 1
      border_weights = weights + ignore_mask
  
      loss = 0
      class_weights = None
      for i in range(n):
          if self.calculate_weights:
              class_weights = self.calculate_weights(label[i])
          loss = loss + self.custom_nll(
              logit[i].unsqueeze(0),
              label[i].unsqueeze(0),
              class_weights=class_weights,
              border_weights=border_weights,
              ignore_mask=ignore_mask[i],
          )
      return loss
  
file_path: PaddleSeg/paddleseg/models/losses/decoupledsegnet_relax_boundary_loss.py
imports: import numpy
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from scipy.ndimage import shift
  from paddleseg.cvlibs import manager
label_desc: Use image node_id 5 for calling the RelaxBoundaryLoss obj's underlying member method code with example usage: obj.forward(logit, label) and returns: loss