class_docstr: Randomly crop images and make sure to contain at least one intact
  instance.
  
  Required Keys:
  
  - img
  - gt_polygons
  - gt_bboxes
  - gt_bboxes_labels
  - gt_ignored
  - gt_texts (optional)
  
  Modified Keys:
  
  - img
  - img_shape
  - gt_polygons
  - gt_bboxes
  - gt_bboxes_labels
  - gt_ignored
  - gt_texts (optional)
  
  Args:
      min_side_ratio (float): The ratio of the shortest edge of the cropped
          image to the original image size.
class_docstr_tok: ["Randomly","crop","images","and","make","sure","to","contain","at","least","one","intact","instance",".","Required","Keys",":","-","img","-","gt_polygons","-","gt_bboxes","-","gt_bboxes_labels","-","gt_ignored","-","gt_texts","(","optional",")","Modified","Keys",":","-","img","-","img_shape","-","gt_polygons","-","gt_bboxes","-","gt_bboxes_labels","-","gt_ignored","-","gt_texts","(","optional",")","Args",":","min_side_ratio","(","float",")",":","The","ratio","of","the","shortest","edge","of","the","cropped","image","to","the","original","image","size","."]
docstr: Crop image given a bbox region.
  Args:
      img (ndarray): Image.
      bbox (ndarray): Cropping region in shape (4, )
  
  Returns:
      ndarray: Cropped image.
docstr_tok: ["Crop","image","given","a","bbox","region",".","Args",":","img","(","ndarray",")",":","Image",".","bbox","(","ndarray",")",":","Cropping","region","in","shape","(","4",",",")","Returns",":","ndarray",":","Cropped","image","."]
code: def _crop_img(self, img: np.ndarray, bbox: np.ndarray) -> np.ndarray:
      """Crop image given a bbox region.
      Args:
          img (ndarray): Image.
          bbox (ndarray): Cropping region in shape (4, )
  
      Returns:
          ndarray: Cropped image.
      """
      assert img.ndim == 3
      h, w, _ = img.shape
      assert 0 <= bbox[1] < bbox[3] <= h
      assert 0 <= bbox[0] < bbox[2] <= w
      return img[bbox[1] : bbox[3], bbox[0] : bbox[2]]
  
imports: import math
  from typing import Dict, Tuple
  import cv2
  import mmcv
  import numpy
  from mmcv.transforms import Resize
  from mmcv.transforms.base import BaseTransform
  from mmcv.transforms.utils import avoid_cache_randomness, cache_randomness
  from mmocr.registry import TRANSFORMS
  from mmocr.utils import bbox2poly, crop_polygon, is_poly_inside_rect, poly2bbox, poly2shapely, poly_make_valid, remove_pipeline_elements, rescale_polygon, shapely2poly
  from .wrappers import ImgAugWrapper
label_desc: Use image node_id 4 for calling the RandomCrop obj's underlying member method code with example usage: obj._crop_img(img, bbox) and returns: img