code: def check_frame(
      image,
      frame_index,
      total_frames,
      channel_dim,
      roi,
      w,
      h,
      aspect_ratio_range,
      area_range,
      value_range,
  ):
      x0, y0, x1, y1, f = analyze_frame(image, channel_dim)
      assert f == frame_index * value_range // total_frames
      out_h, out_w = (
          image.shape[:2] if channel_dim != 0 else image.shape[1:3]
      )
      xeps = np.ceil(2 + 2 * w / out_w)
      yeps = np.ceil(2 + 2 * h / out_h)
      if frame_index == 0:
          roi_w_max = min((x1 - x0) * w / value_range + xeps, w)
          roi_w_min = max((x1 - x0) * w / value_range - xeps, 1)
          roi_h_max = min((y1 - y0) * h / value_range + yeps, h)
          roi_h_min = max((y1 - y0) * h / value_range - xeps, 1)
          ratio_min = roi_w_min / roi_h_max
          ratio_max = roi_w_max / roi_h_min
          area_min = roi_w_min * roi_h_min / (w * h)
          area_max = roi_w_max * roi_h_max / (w * h)
  
          assert (
              ratio_max >= aspect_ratio_range[0]
              and ratio_min <= aspect_ratio_range[1]
          ), "aspect ratio estimated at {}..{} outside valid range [{} .. {}]".format(
              ratio_min, ratio_min, *aspect_ratio_range
          )
          assert (
              area_max >= area_range[0] and area_min <= area_range[1]
          ), "area estimated at {}..{} outside valiid range [{} .. {}]".format(
              area_min, area_max, *area_range
          )
          return x0, y0, x1, y1
      else:
          assert (x0, y0, x1, y1) == roi
          return roi
  
file_path: DALI/dali/test/python/operator_2/test_random_resized_crop.py
imports: import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import test_utils
label_desc: Use image node_id 3 for calling a global function with example usage: check_frame(image, frame_index, total_frames, channel_dim, roi, w, h, aspect_ratio_range, area_range, value_range) and returns: x0,  y0,  x1,  y1, roi