class_docstr: The class for implementing FCENet loss
  FCENet(CVPR2021): Fourier Contour Embedding for Arbitrary-shaped
      Text Detection
  
  [https://arxiv.org/abs/2104.10442]
  
  Args:
      fourier_degree (int) : The maximum Fourier transform degree k.
      num_sample (int) : The sampling points number of regression
          loss. If it is too small, fcenet tends to be overfitting.
      ohem_ratio (float): the negative/positive ratio in OHEM.
class_docstr_tok: ["The","class","for","implementing","FCENet","loss","FCENet","(","CVPR2021",")",":","Fourier","Contour","Embedding","for","Arbitrary-shaped","Text","Detection","[","https",":","\/\/arxiv.org\/abs\/2104.10442","]","Args",":","fourier_degree","(","int",")",":","The","maximum","Fourier","transform","degree","k.","num_sample","(","int",")",":","The","sampling","points","number","of","regression","loss",".","If","it","is","too","small",",","fcenet","tends","to","be","overfitting",".","ohem_ratio","(","float",")",":","the","negative\/positive","ratio","in","OHEM","."]
code: def ohem(self, predict, target, train_mask):
      pos = (target * train_mask).astype("bool")
      neg = ((1 - target) * train_mask).astype("bool")
  
      pos2 = paddle.concat([pos.unsqueeze(1), pos.unsqueeze(1)], axis=1)
      neg2 = paddle.concat([neg.unsqueeze(1), neg.unsqueeze(1)], axis=1)
  
      n_pos = pos.astype("float32").sum()
  
      if n_pos.item() > 0:
          loss_pos = F.cross_entropy(
              predict.masked_select(pos2).reshape([-1, 2]),
              target.masked_select(pos).astype("int64"),
              reduction="sum",
          )
          loss_neg = F.cross_entropy(
              predict.masked_select(neg2).reshape([-1, 2]),
              target.masked_select(neg).astype("int64"),
              reduction="none",
          )
          n_neg = min(
              int(neg.astype("float32").sum().item()),
              int(self.ohem_ratio * n_pos.astype("float32")),
          )
      else:
          loss_pos = paddle.to_tensor(0.0)
          loss_neg = F.cross_entropy(
              predict.masked_select(neg2).reshape([-1, 2]),
              target.masked_select(neg).astype("int64"),
              reduction="none",
          )
          n_neg = 100
      if len(loss_neg) > n_neg:
          loss_neg, _ = paddle.topk(loss_neg, n_neg)
  
      return (loss_pos + loss_neg.sum()) / (n_pos + n_neg).astype(
          "float32"
      )
  
file_path: PaddleOCR/ppocr/losses/det_fce_loss.py
imports: import numpy
  from paddle import nn
  import paddle
  import paddle.nn.functional
  from functools import partial
label_desc: Use image node_id 4 for calling the FCELoss obj's underlying member method code with example usage: obj.ohem(predict, target, train_mask) and returns: unknown