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 relax_onehot(self, label, num_classes):
      # pad label, and let ignore_index as num_classes
      if len(label.shape) == 3:
          label = label.unsqueeze(1)
      h, w = label.shape[-2], label.shape[-1]
      label = F.pad(label, [self.border] * 4, value=num_classes)
      label = label.squeeze(1)
      ignore_mask = (label == self.ignore_index).astype("int64")
      label = label * (1 - ignore_mask) + num_classes * ignore_mask
  
      onehot = 0
      for i in range(-self.border, self.border + 1):
          for j in range(-self.border, self.border + 1):
              h_start, h_end = 1 + i, h + 1 + i
              w_start, w_end = 1 + j, w + 1 + j
              label_ = label[:, h_start:h_end, w_start:w_end]
              onehot_ = F.one_hot(label_, num_classes + 1)
              onehot += onehot_
      onehot = (onehot > 0).astype("int64")
      onehot = paddle.transpose(onehot, (0, 3, 1, 2))
  
      return onehot
  
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 2 for calling the RelaxBoundaryLoss obj's underlying member method code with example usage: obj.relax_onehot(label, num_classes) and returns: onehot