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.
      negative_ratio (float or int): Maximum ratio of negative
          samples to positive ones in OHEM. Defaults to 3.
      resample_step (float): The step size for resampling the text center
          line (TCL). It's better not to exceed half of the minimum width.
      center_region_shrink_ratio (float): The shrink ratio of text center
          region.
      level_size_divisors (tuple(int)): The downsample ratio on each level.
      level_proportion_range (tuple(tuple(int))): The range of text sizes
          assigned to each level.
      loss_tr (dict) : The loss config used to calculate the text region
          loss. Defaults to dict(type='MaskedBalancedBCELoss').
      loss_tcl (dict) : The loss config used to calculate the text center
          line loss. Defaults to dict(type='MaskedBCELoss').
      loss_reg_x (dict) : The loss config used to calculate the regression
          loss on x axis. Defaults to dict(type='MaskedSmoothL1Loss').
      loss_reg_y (dict) : The loss config used to calculate the regression
          loss on y axis. Defaults to dict(type='MaskedSmoothL1Loss').
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",".","negative_ratio","(","float","or","int",")",":","Maximum","ratio","of","negative","samples","to","positive","ones","in","OHEM",".","Defaults","to","3.","resample_step","(","float",")",":","The","step","size","for","resampling","the","text","center","line","(","TCL",")",".","It","'s","better","not","to","exceed","half","of","the","minimum","width",".","center_region_shrink_ratio","(","float",")",":","The","shrink","ratio","of","text","center","region",".","level_size_divisors","(","tuple","(","int",")",")",":","The","downsample","ratio","on","each","level",".","level_proportion_range","(","tuple","(","tuple","(","int",")",")",")",":","The","range","of","text","sizes","assigned","to","each","level",".","loss_tr","(","dict",")",":","The","loss","config","used","to","calculate","the","text","region","loss",".","Defaults","to","dict","(","type='MaskedBalancedBCELoss","'",")",".","loss_tcl","(","dict",")",":","The","loss","config","used","to","calculate","the","text","center","line","loss",".","Defaults","to","dict","(","type='MaskedBCELoss","'",")",".","loss_reg_x","(","dict",")",":","The","loss","config","used","to","calculate","the","regression","loss","on","x","axis",".","Defaults","to","dict","(","type='MaskedSmoothL1Loss","'",")",".","loss_reg_y","(","dict",")",":","The","loss","config","used","to","calculate","the","regression","loss","on","y","axis",".","Defaults","to","dict","(","type='MaskedSmoothL1Loss","'",")","."]
docstr: Compute FCENet loss.
  
  Args:
      preds (list[dict]): A list of dict with keys of ``cls_res``,
          ``reg_res`` corresponds to the classification result and
          regression result computed from the input tensor with the
          same index. They have the shapes of :math:`(N, C_{cls,i}, H_i,
          W_i)` and :math: `(N, C_{out,i}, H_i, W_i)`.
      data_samples (list[TextDetDataSample]): The data samples.
  
  Returns:
      dict: The dict for fcenet losses with loss_text, loss_center,
          loss_reg_x and loss_reg_y.
docstr_tok: ["Compute","FCENet","loss",".","Args",":","preds","(","list","[","dict","]",")",":","A","list","of","dict","with","keys","of","``","cls_res","``",",","``","reg_res","``","corresponds","to","the","classification","result","and","regression","result","computed","from","the","input","tensor","with","the","same","index",".","They","have","the","shapes","of",":","math",":","`","(","N",",","C_","{","cls",",","i","}",",","H_i",",","W_i",")","`","and",":","math",":","`","(","N",",","C_","{","out",",","i","}",",","H_i",",","W_i",")","`",".","data_samples","(","list","[","TextDetDataSample","]",")",":","The","data","samples",".","Returns",":","dict",":","The","dict","for","fcenet","losses","with","loss_text",",","loss_center",",","loss_reg_x","and","loss_reg_y","."]
code: def forward(
      self,
      preds: Sequence[Dict],
      data_samples: Sequence[TextDetDataSample],
  ) -> Dict:
      """Compute FCENet loss.
  
      Args:
          preds (list[dict]): A list of dict with keys of ``cls_res``,
              ``reg_res`` corresponds to the classification result and
              regression result computed from the input tensor with the
              same index. They have the shapes of :math:`(N, C_{cls,i}, H_i,
              W_i)` and :math: `(N, C_{out,i}, H_i, W_i)`.
          data_samples (list[TextDetDataSample]): The data samples.
  
      Returns:
          dict: The dict for fcenet losses with loss_text, loss_center,
              loss_reg_x and loss_reg_y.
      """
      assert isinstance(preds, list) and len(preds) == 3
      p3_maps, p4_maps, p5_maps = self.get_targets(data_samples)
      device = preds[0]["cls_res"].device
      # to device
      gts = [p3_maps.to(device), p4_maps.to(device), p5_maps.to(device)]
  
      losses = multi_apply(self.forward_single, preds, gts)
  
      loss_tr = torch.tensor(0.0, device=device).float()
      loss_tcl = torch.tensor(0.0, device=device).float()
      loss_reg_x = torch.tensor(0.0, device=device).float()
      loss_reg_y = torch.tensor(0.0, device=device).float()
  
      for idx, loss in enumerate(losses):
          if idx == 0:
              loss_tr += sum(loss)
          elif idx == 1:
              loss_tcl += sum(loss)
          elif idx == 2:
              loss_reg_x += sum(loss)
          else:
              loss_reg_y += sum(loss)
  
      results = dict(
          loss_text=loss_tr,
          loss_center=loss_tcl,
          loss_reg_x=loss_reg_x,
          loss_reg_y=loss_reg_y,
      )
  
      return results
  
imports: from typing import Dict, List, Optional, Sequence, Tuple, Union
  import cv2
  import numpy
  import torch
  from mmdet.models.utils import multi_apply
  from numpy.fft import fft
  from numpy.linalg import norm
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils.typing_utils import ArrayLike
  from .textsnake_module_loss import TextSnakeModuleLoss
label_desc: Use image node_id 2 for calling the FCEModuleLoss obj's underlying member method code with example usage: obj.forward(preds, data_samples) and returns: results