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","."]
code: def custom_nll(
      self,
      logit,
      label,
      class_weights=None,
      border_weights=None,
      ignore_mask=None,
  ):
      soft = F.softmax(logit, axis=1)
      # calculate the valid soft where label is 1.
      soft_label = (
          (soft * label[:, :-1, :, :]).sum(1, keepdim=True)
      ) * (label[:, :-1, :, :].astype("float32"))
      soft = soft * (1 - label[:, :-1, :, :]) + soft_label
      logsoft = paddle.log(soft)
      if class_weights is not None:
          logsoft = class_weights.unsqueeze((0, 2, 3))
      logsoft = label[:, :-1, :, :] * logsoft
      logsoft = logsoft.sum(1)
      # border loss is divided equally
      logsoft = -1 / border_weights * logsoft * (1.0 - ignore_mask)
      n, _, h, w = label.shape
      logsoft = logsoft.sum() / (n * h * w - ignore_mask.sum() + 1)
      return logsoft
  
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 4 for calling the RelaxBoundaryLoss obj's underlying member method code with example usage: obj.custom_nll(logit, label, class_weights, border_weights, ignore_mask) and returns: logsoft