code: def test_rotate_sample():
      img = tf.ones((200, 100, 3), dtype=tf.float32)
      boxes = np.array([0, 0, 100, 200])[None, ...]
      polys = np.stack(
          (
              boxes[..., [0, 1]],
              boxes[..., [2, 1]],
              boxes[..., [2, 3]],
              boxes[..., [0, 3]],
          ),
          axis=1,
      )
      rel_boxes = np.array([0, 0, 1, 1], dtype=np.float32)[None, ...]
      rel_polys = np.stack(
          (
              rel_boxes[..., [0, 1]],
              rel_boxes[..., [2, 1]],
              rel_boxes[..., [2, 3]],
              rel_boxes[..., [0, 3]],
          ),
          axis=1,
      )
  
      # No angle
      rotated_img, rotated_geoms = rotate_sample(img, boxes, 0, False)
      assert tf.math.reduce_all(rotated_img == img) and np.all(
          rotated_geoms == rel_polys
      )
      rotated_img, rotated_geoms = rotate_sample(img, boxes, 0, True)
      assert tf.math.reduce_all(rotated_img == img) and np.all(
          rotated_geoms == rel_polys
      )
      rotated_img, rotated_geoms = rotate_sample(img, polys, 0, False)
      assert tf.math.reduce_all(rotated_img == img) and np.all(
          rotated_geoms == rel_polys
      )
      rotated_img, rotated_geoms = rotate_sample(img, polys, 0, True)
      assert tf.math.reduce_all(rotated_img == img) and np.all(
          rotated_geoms == rel_polys
      )
  
      # No expansion
      expected_img = np.zeros((200, 100, 3), dtype=np.float32)
      expected_img[50:150] = 1
      expected_img = tf.convert_to_tensor(expected_img)
      expected_polys = np.array(
          [[0, 0.75], [0, 0.25], [1, 0.25], [1, 0.75]]
      )[None, ...]
      rotated_img, rotated_geoms = rotate_sample(img, boxes, 90, False)
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(img, polys, 90, False)
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(
          img, rel_boxes, 90, False
      )
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(
          img, rel_polys, 90, False
      )
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
  
      # Expansion
      expected_img = tf.ones((100, 200, 3), dtype=tf.float32)
      expected_polys = np.array(
          [[0, 1], [0, 0], [1, 0], [1, 1]], dtype=np.float32
      )[None, ...]
      rotated_img, rotated_geoms = rotate_sample(img, boxes, 90, True)
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(img, polys, 90, True)
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(
          img, rel_boxes, 90, True
      )
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
      rotated_img, rotated_geoms = rotate_sample(
          img, rel_polys, 90, True
      )
      assert tf.math.reduce_all(rotated_img == expected_img) and np.all(
          rotated_geoms == expected_polys
      )
  
      with pytest.raises(AssertionError):
          rotate_sample(img, boxes[None, ...], 90, False)
  
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 13 for calling a global function with example usage: test_rotate_sample() without return types