code: def test_rrc_params(
      height: int, width: int, size: Union[int, Tuple[int, int]]
  ) -> None:
      # this function tests the RandomResizedCrop Params
      parser = argparse.ArgumentParser()
      parser = pil_transforms.RandomResizedCrop.add_arguments(parser)
  
      opts = parser.parse_args([])
  
      setattr(
          opts,
          "image_augmentation.random_resized_crop.interpolation",
          "bilinear",
      )
  
      # create dummy image
      image = Image.new("RGB", (height, width))
  
      # This is adapted from torchvision
      # https://github.com/pytorch/vision/blob/78ffda7eb952571df728e2ae49c2aca788596138/test/test_transforms.py#L308
      epsilon = 0.05
      min_scale = 0.25
      scale_min = max(round(random.random(), 2), min_scale)
      scale = (scale_min, scale_min + round(random.random(), 2))
      aspect_min = max(round(random.random(), 2), epsilon)
      aspect_ratio = (
          aspect_min,
          aspect_min + round(random.random(), 2),
      )
  
      setattr(
          opts, "image_augmentation.random_resized_crop.scale", scale
      )
      setattr(
          opts,
          "image_augmentation.random_resized_crop.aspect_ratio",
          aspect_ratio,
      )
      random_resized_crop = pil_transforms.RandomResizedCrop(
          opts=opts, size=size
      )
  
      i, j, h, w = random_resized_crop.get_rrc_params(image)
  
      assert isinstance(i, int)
      assert isinstance(j, int)
      assert isinstance(h, int)
      assert isinstance(w, int)
  
      obtained_aspect_ratio = w / h
      # expected aspect ratio should satisfy either of following conditions (within certain margin):
      # 1. min(aspect_ratio) - e <= obtained_aspect_ratio <= max(aspect_ratio) + e
      # 2. obtained_aspect_ratio = 1.
      assert (
          min(aspect_ratio) - epsilon
          <= obtained_aspect_ratio
          <= max(aspect_ratio) + epsilon
      ) or (obtained_aspect_ratio == 1.0)
  
file_path: ml-cvnets/tests/transforms/test_image.py
imports: import argparse
  import random
  from typing import Tuple, Union
  import pytest
  import torch
  from PIL import Image
  from data.transforms import image_pil
  from data.transforms import image_torch
label_desc: Use image node_id 1 for calling a global function with example usage: test_rrc_params(height, width, size) without return types