class_docstr: Resize the image to the base shape, downsample it with gaussian pyramid,
  and rescale it back to original size.
  
  Adapted from https://github.com/FangShancheng/ABINet.
  
  Required Keys:
  
  - img (ndarray)
  
  Modified Keys:
  
  - img (ndarray)
  
  Args:
      factor (int): The decay factor from base size, or the number of
          downsampling operations from the base layer.
      base_shape (tuple[int, int]): The shape (width, height) of the base
          layer of the pyramid.
      randomize_factor (bool): If True, the final factor would be a random
          integer in [0, factor].
class_docstr_tok: ["Resize","the","image","to","the","base","shape",",","downsample","it","with","gaussian","pyramid",",","and","rescale","it","back","to","original","size",".","Adapted","from","https",":","\/\/github.com\/FangShancheng\/ABINet",".","Required","Keys",":","-","img","(","ndarray",")","Modified","Keys",":","-","img","(","ndarray",")","Args",":","factor","(","int",")",":","The","decay","factor","from","base","size",",","or","the","number","of","downsampling","operations","from","the","base","layer",".","base_shape","(","tuple","[","int",",","int","]",")",":","The","shape","(","width",",","height",")","of","the","base","layer","of","the","pyramid",".","randomize_factor","(","bool",")",":","If","True",",","the","final","factor","would","be","a","random","integer","in","[","0",",","factor","]","."]
code: def __init__(
      self,
      factor: int = 4,
      base_shape: Tuple[int, int] = (128, 512),
      randomize_factor: bool = True,
  ) -> None:
      if not isinstance(factor, int):
          raise TypeError(
              "`factor` should be an integer, "
              f"but got {type(factor)} instead"
          )
      if not isinstance(base_shape, (list, tuple)):
          raise TypeError(
              "`base_shape` should be a list or tuple, "
              f"but got {type(base_shape)} instead"
          )
      if not len(base_shape) == 2:
          raise ValueError("`base_shape` should contain two integers")
      if not isinstance(base_shape[0], int) or not isinstance(
          base_shape[1], int
      ):
          raise ValueError("`base_shape` should contain two integers")
      if not isinstance(randomize_factor, bool):
          raise TypeError(
              "`randomize_factor` should be a bool, "
              f"but got {type(randomize_factor)} instead"
          )
  
      self.factor = factor
      self.randomize_factor = randomize_factor
      self.base_w, self.base_h = base_shape
  
imports: import math
  import random
  from typing import Dict, List, Optional, Tuple
  import cv2
  import mmcv
  import numpy
  from mmcv.transforms.base import BaseTransform
  from mmcv.transforms.utils import cache_randomness
  from mmocr.registry import TRANSFORMS
label_desc: Use image node_id 1 to create a new PyramidRescale object from inherited base classes: BaseTransform with example: obj = PyramidRescale(factor, base_shape, randomize_factor)