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: Resample one polygon with n points on its boundary.
  
  Args:
      polygon (list[ndarray]): The input polygon.
      n (int): The number of resampled points. Defaults to 400.
  Returns:
      ndarray: The resampled polygon.
docstr_tok: ["Resample","one","polygon","with","n","points","on","its","boundary",".","Args",":","polygon","(","list","[","ndarray","]",")",":","The","input","polygon",".","n","(","int",")",":","The","number","of","resampled","points",".","Defaults","to","400",".","Returns",":","ndarray",":","The","resampled","polygon","."]
code: def _resample_polygon(
      self, polygon: ArrayLike, n: int = 400
  ) -> np.ndarray:
      """Resample one polygon with n points on its boundary.
  
      Args:
          polygon (list[ndarray]): The input polygon.
          n (int): The number of resampled points. Defaults to 400.
      Returns:
          ndarray: The resampled polygon.
      """
      length = []
  
      for i in range(len(polygon)):
          p1 = polygon[i]
          if i == len(polygon) - 1:
              p2 = polygon[0]
          else:
              p2 = polygon[i + 1]
          length.append(
              ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
          )
  
      total_length = sum(length)
      n_on_each_line = (np.array(length) / (total_length + 1e-8)) * n
      n_on_each_line = n_on_each_line.astype(np.int32)
      new_polygon = []
  
      for i in range(len(polygon)):
          num = n_on_each_line[i]
          p1 = polygon[i]
          if i == len(polygon) - 1:
              p2 = polygon[0]
          else:
              p2 = polygon[i + 1]
  
          if num == 0:
              continue
  
          dxdy = (p2 - p1) / num
          for j in range(num):
              point = p1 + dxdy * j
              new_polygon.append(point)
  
      return np.array(new_polygon)
  
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 10 for calling the FCEModuleLoss obj's underlying member method code with example usage: obj._resample_polygon(polygon, n) and returns: np