class_docstr: Implements the point cross entropy loss function.
  
  The original article refers to
  Kirillov A, Wu Y, He K, et al. "PointRend: Image Segmentation As Rendering."
  (https://arxiv.org/abs/1912.08193).
  
  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``.
      top_k_percent_pixels (float, optional): the value lies in [0.0, 1.0]. When its value < 1.0, only compute the loss for
          the top k percent pixels (e.g., the top 20% pixels). This is useful for hard pixel mining. Default ``1.0``.
      data_format (str, optional): The tensor format to use, 'NCHW' or 'NHWC'. Default ``'NCHW'``.
docstr: Forward computation.
  
  Args:
      logits (Tensor): Logit tensor, the data type is float32, float64. Shape is
          (logit,points). logit'shape: [N, C, point_num]. logit'shape:[N, point_num, 2], where C is number of classes.
      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.
      semantic_weights (Tensor, optional): Weights about loss for each pixels, shape is the same as label. Default: None.
docstr_tok: ["Forward","computation",".","Args",":","logits","(","Tensor",")",":","Logit","tensor",",","the","data","type","is","float32",",","float64",".","Shape","is","(","logit",",","points",")",".","logit'shape",":","[","N",",","C",",","point_num","]",".","logit'shape",":","[","N",",","point_num",",","2","]",",","where","C","is","number","of","classes",".","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.","semantic_weights","(","Tensor",",","optional",")",":","Weights","about","loss","for","each","pixels",",","shape","is","the","same","as","label",".","Default",":","None","."]
code: def forward(self, logits, label, semantic_weights=None):
      """
      Forward computation.
  
      Args:
          logits (Tensor): Logit tensor, the data type is float32, float64. Shape is
              (logit,points). logit'shape: [N, C, point_num]. logit'shape:[N, point_num, 2], where C is number of classes.
          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.
          semantic_weights (Tensor, optional): Weights about loss for each pixels, shape is the same as label. Default: None.
      """
      # for loss
      logit, points = logits  # [N, C, point_num],[N, point_num, 2]
      label = label.unsqueeze(1)  # [N,1,H,W]
      label = point_sample(
          label.astype("float32"),
          points,
          mode="nearest",
          align_corners=self.align_corners,
      )  # [N, 1, point_num]
      label = paddle.squeeze(label, axis=1).astype("int64")  # [N, xx]
  
      channel_axis = 1 if self.data_format == "NCHW" else -1
      if self.weight is not None and logit.shape[channel_axis] != len(
          self.weight
      ):
          raise ValueError(
              "The number of weights = {} must be the same as the number of classes = {}.".format(
                  len(self.weight), logit.shape[1]
              )
          )
  
      logit = paddle.transpose(logit, [0, 2, 1])
      no_ignore_label = label
      # no_ignore_label[label==self.ignore_index] = 0
      loss = F.cross_entropy(
          logit,
          no_ignore_label,
          ignore_index=self.ignore_index,
          reduction="none",
      )
  
      mask = label != self.ignore_index
      mask = paddle.cast(mask, "float32")
  
      loss = loss * mask
      if semantic_weights is not None:
          loss = loss * semantic_weights
  
      if self.weight is not None:
          _one_hot = F.one_hot(label, logit.shape[-1])
          _one_hot_weight = _one_hot * self.weight
          loss = loss * _one_hot_weight.argmax(-1)
          coef = paddle.sum(_one_hot_weight, axis=-1)
          # coef = paddle.ones_like(label)
      else:
          coef = paddle.ones_like(label)
  
      label.stop_gradient = True
      mask.stop_gradient = True
      if self.top_k_percent_pixels == 1.0:
          avg_loss = paddle.mean(loss) / (
              paddle.mean(mask * coef) + self.EPS
          )
          return avg_loss
  
      loss = loss.reshape((-1,))
      top_k_pixels = int(self.top_k_percent_pixels * loss.numel())
      loss, indices = paddle.topk(loss, top_k_pixels)
      coef = coef.reshape((-1,))
      coef = paddle.gather(coef, indices)
      coef.stop_gradient = True
  
      return loss.mean() / (paddle.mean(coef) + self.EPS)
  
file_path: PaddleSeg/paddleseg/models/losses/point_cross_entropy_loss.py
imports: import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager
label_desc: Use image node_id 2 for calling the PointCrossEntropyLoss obj's underlying member method code with example usage: obj.forward(logits, label, semantic_weights) and returns: unknown, avg_loss