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 calculate_weights(self, label):
      hist = paddle.sum(label, axis=(1, 2)) * 1.0 / label.sum()
      hist = ((hist != 0) * self.upper_bound * (1 - hist)) + 1
  
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 3 for calling the RelaxBoundaryLoss obj's underlying member method code with example usage: obj.calculate_weights(label) without return types