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 text center region mask.
  
  Args:
      img_size (tuple): The image size of (height, width).
      text_polys (list[ndarray]): The list of text polygons.
  
  Returns:
      ndarray: The text center region mask.
docstr_tok: ["Generate","text","center","region","mask",".","Args",":","img_size","(","tuple",")",":","The","image","size","of","(","height",",","width",")",".","text_polys","(","list","[","ndarray","]",")",":","The","list","of","text","polygons",".","Returns",":","ndarray",":","The","text","center","region","mask","."]
code: def _generate_center_region_mask(
      self, img_size: Tuple[int, int], text_polys: ArrayLike
  ) -> np.ndarray:
      """Generate text center region mask.
  
      Args:
          img_size (tuple): The image size of (height, width).
          text_polys (list[ndarray]): The list of text polygons.
  
      Returns:
          ndarray: The text center region mask.
      """
  
      assert isinstance(img_size, tuple)
  
      h, w = img_size
  
      center_region_mask = np.zeros((h, w), np.uint8)
  
      center_region_boxes = []
      for poly in text_polys:
          polygon_points = poly.reshape(-1, 2)
          _, _, top_line, bot_line = self._reorder_poly_edge(
              polygon_points
          )
          (
              resampled_top_line,
              resampled_bot_line,
          ) = self._resample_sidelines(
              top_line, bot_line, self.resample_step
          )
          resampled_bot_line = resampled_bot_line[::-1]
          center_line = (resampled_top_line + resampled_bot_line) / 2
  
          line_head_shrink_len = (
              norm(resampled_top_line[0] - resampled_bot_line[0]) / 4.0
          )
          line_tail_shrink_len = (
              norm(resampled_top_line[-1] - resampled_bot_line[-1])
              / 4.0
          )
          head_shrink_num = int(
              line_head_shrink_len // self.resample_step
          )
          tail_shrink_num = int(
              line_tail_shrink_len // self.resample_step
          )
          if len(center_line) > head_shrink_num + tail_shrink_num + 2:
              center_line = center_line[
                  head_shrink_num : len(center_line) - tail_shrink_num
              ]
              resampled_top_line = resampled_top_line[
                  head_shrink_num : len(resampled_top_line)
                  - tail_shrink_num
              ]
              resampled_bot_line = resampled_bot_line[
                  head_shrink_num : len(resampled_bot_line)
                  - tail_shrink_num
              ]
  
          for i in range(0, len(center_line) - 1):
              tl = (
                  center_line[i]
                  + (resampled_top_line[i] - center_line[i])
                  * self.center_region_shrink_ratio
              )
              tr = (
                  center_line[i + 1]
                  + (resampled_top_line[i + 1] - center_line[i + 1])
                  * self.center_region_shrink_ratio
              )
              br = (
                  center_line[i + 1]
                  + (resampled_bot_line[i + 1] - center_line[i + 1])
                  * self.center_region_shrink_ratio
              )
              bl = (
                  center_line[i]
                  + (resampled_bot_line[i] - center_line[i])
                  * self.center_region_shrink_ratio
              )
              current_center_box = np.vstack([tl, tr, br, bl]).astype(
                  np.int32
              )
              center_region_boxes.append(current_center_box)
  
      cv2.fillPoly(center_region_mask, center_region_boxes, 1)
      return center_region_mask
  
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 7 for calling the FCEModuleLoss obj's underlying member method code with example usage: obj._generate_center_region_mask(img_size, text_polys) and returns: center_region_mask