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: Generate Fourier coefficient maps.
  
  Args:
      img_size (tuple): The image size of (height, width).
      text_polys (list[ndarray]): The list of text polygons.
  
  Returns:
      tuple(ndarray, ndarray):
  
      - fourier_real_map (ndarray): The Fourier coefficient real part
          maps.
      - fourier_image_map (ndarray): The Fourier coefficient image part
          maps.
docstr_tok: ["Generate","Fourier","coefficient","maps",".","Args",":","img_size","(","tuple",")",":","The","image","size","of","(","height",",","width",")",".","text_polys","(","list","[","ndarray","]",")",":","The","list","of","text","polygons",".","Returns",":","tuple","(","ndarray",",","ndarray",")",":","-","fourier_real_map","(","ndarray",")",":","The","Fourier","coefficient","real","part","maps",".","-","fourier_image_map","(","ndarray",")",":","The","Fourier","coefficient","image","part","maps","."]
code: def _generate_fourier_maps(
      self, img_size: Tuple[int, int], text_polys: ArrayLike
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Generate Fourier coefficient maps.
  
      Args:
          img_size (tuple): The image size of (height, width).
          text_polys (list[ndarray]): The list of text polygons.
  
      Returns:
          tuple(ndarray, ndarray):
  
          - fourier_real_map (ndarray): The Fourier coefficient real part
              maps.
          - fourier_image_map (ndarray): The Fourier coefficient image part
              maps.
      """
  
      assert isinstance(img_size, tuple)
  
      h, w = img_size
      k = self.fourier_degree
      real_map = np.zeros((k * 2 + 1, h, w), dtype=np.float32)
      imag_map = np.zeros((k * 2 + 1, h, w), dtype=np.float32)
  
      for poly in text_polys:
          mask = np.zeros((h, w), dtype=np.uint8)
          polygon = np.array(poly).reshape((1, -1, 2))
          cv2.fillPoly(mask, polygon.astype(np.int32), 1)
          fourier_coeff = self._cal_fourier_signature(polygon[0], k)
          for i in range(-k, k + 1):
              if i != 0:
                  real_map[i + k, :, :] = (
                      mask * fourier_coeff[i + k, 0]
                      + (1 - mask) * real_map[i + k, :, :]
                  )
                  imag_map[i + k, :, :] = (
                      mask * fourier_coeff[i + k, 1]
                      + (1 - mask) * imag_map[i + k, :, :]
                  )
              else:
                  yx = np.argwhere(mask > 0.5)
                  k_ind = np.ones((len(yx)), dtype=np.int64) * k
                  y, x = yx[:, 0], yx[:, 1]
                  real_map[k_ind, y, x] = fourier_coeff[k, 0] - x
                  imag_map[k_ind, y, x] = fourier_coeff[k, 1] - y
  
      return real_map, imag_map
  
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 8 for calling the FCEModuleLoss obj's underlying member method code with example usage: obj._generate_fourier_maps(img_size, text_polys) and returns: real_map,  imag_map