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: Applying random crop on results.
  Args:
      results (dict): Result dict contains the data to transform.
  
  Returns:
      dict: The transformed data.
docstr_tok: ["Applying","random","crop","on","results",".","Args",":","results","(","dict",")",":","Result","dict","contains","the","data","to","transform",".","Returns",":","dict",":","The","transformed","data","."]
code: def transform(self, results: Dict) -> Dict:
      """Applying random crop on results.
      Args:
          results (dict): Result dict contains the data to transform.
  
      Returns:
          dict: The transformed data.
      """
      if len(results["gt_polygons"]) < 1:
          return results
  
      crop_box = self._sample_crop_box(results["img"].shape, results)
      img = self._crop_img(results["img"], crop_box)
      results["img"] = img
      results["img_shape"] = img.shape[:2]
      crop_x = crop_box[0]
      crop_y = crop_box[1]
      crop_w = crop_box[2] - crop_box[0]
      crop_h = crop_box[3] - crop_box[1]
  
      labels = results["gt_bboxes_labels"]
      valid_labels = []
      ignored = results["gt_ignored"]
      valid_ignored = []
      if "gt_texts" in results:
          valid_texts = []
          texts = results["gt_texts"]
  
      polys = results["gt_polygons"]
      valid_polys = []
      for idx, poly in enumerate(polys):
          poly = poly.reshape(-1, 2)
          poly = (poly - (crop_x, crop_y)).flatten()
          if is_poly_inside_rect(poly, [0, 0, crop_w, crop_h]):
              valid_polys.append(poly)
              valid_labels.append(labels[idx])
              valid_ignored.append(ignored[idx])
              if "gt_texts" in results:
                  valid_texts.append(texts[idx])
      results["gt_polygons"] = valid_polys
      results["gt_bboxes_labels"] = np.array(
          valid_labels, dtype=np.int64
      )
      results["gt_ignored"] = np.array(valid_ignored, dtype=bool)
      if "gt_texts" in results:
          results["gt_texts"] = valid_texts
      valid_bboxes = [
          poly2bbox(poly) for poly in results["gt_polygons"]
      ]
      results["gt_bboxes"] = (
          np.array(valid_bboxes).astype(np.float32).reshape(-1, 4)
      )
  
      return results
  
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 5 for calling the RandomCrop obj's underlying member method code with example usage: obj.transform(results) and returns: results, results