code: def test_crop_detection():
      img = tf.ones((50, 50, 3), dtype=tf.float32)
      abs_boxes = np.array(
          [
              [15, 20, 35, 30],
              [5, 10, 10, 20],
          ]
      )
      crop_box = (12 / 50, 23 / 50, 1.0, 1.0)
      c_img, c_boxes = crop_detection(img, abs_boxes, crop_box)
      assert c_img.shape == (26, 37, 3)
      assert c_boxes.shape == (1, 4)
      assert np.all(
          c_boxes == np.array([15 - 12, 0, 35 - 12, 30 - 23])[None, ...]
      )
  
      rel_boxes = np.array(
          [
              [0.3, 0.4, 0.7, 0.6],
              [0.1, 0.2, 0.2, 0.4],
          ]
      )
      c_img, c_boxes = crop_detection(img, rel_boxes, crop_box)
      assert c_img.shape == (26, 37, 3)
      assert c_boxes.shape == (1, 4)
      assert (
          np.abs(
              c_boxes
              - np.array([0.06 / 0.76, 0.0, 0.46 / 0.76, 0.14 / 0.54])[
                  None, ...
              ]
          ).mean()
          < 1e-7
      )
  
      # FP16
      img = tf.ones((50, 50, 3), dtype=tf.float16)
      c_img, _ = crop_detection(img, rel_boxes, crop_box)
      assert c_img.dtype == tf.float16
  
      with pytest.raises(AssertionError):
          crop_detection(img, abs_boxes, (2, 6, 24, 56))
  
imports: import math
  import numpy
  import pytest
  import tensorflow
  from doctr import transforms
  from doctr.transforms.functional import crop_detection, rotate_sample
label_desc: Use image node_id 15 for calling a global function with example usage: test_crop_detection() without return types