code: def test_crop_by_bounding_box() -> None:
      opts = get_config()
      image_size = (10, 10)
      setattr(
          opts,
          "video_augmentation.crop_by_bounding_box.image_size",
          image_size,
      )
      setattr(
          opts,
          "video_augmentation.crop_by_bounding_box.multiplier",
          1.14,
      )
      transform = CropByBoundingBox(opts)
  
      N, T, C, H, W = 2, 3, 5, 81, 81
      video = torch.rand(N, T, C, H, W)
      box_coordinates = torch.concat(
          [
              torch.rand(N, T, 2) * 0.5,
              torch.rand(N, T, 2) * 0.5 + 0.5,
          ],
          dim=2,
      )
  
      x, y = torch.meshgrid(
          torch.linspace(10, 90, H), torch.linspace(1, 9, W)
      )
      video[0, 0, 0, :, :] = (
          x + y
      )  # x values are in {10, 20, ..., 90} and y values are in {1, 2, ..., 9}
      # The bounding box is a small strip at the bottom of the image
      box_coordinates[0, 0, :] = torch.tensor([0, 0.8, 1, 0.9])
  
      data = {
          "samples": {
              "video": video,
          },
          "targets": {
              "traces": {
                  "a_uuid": {
                      "box_coordinates": box_coordinates,
                  }
              }
          },
      }
      result = transform(data)
      assert isinstance(result, dict), f"{type(result)} != dict"
      result_video = result["samples"]["video"]
      assert result_video.shape == (N, T, C, *image_size)
      result_box_coordinates = result["targets"]["traces"]["a_uuid"][
          "box_coordinates"
      ]
      assert result_box_coordinates.shape == (N, T, 4)
      assert torch.all(0 < result_box_coordinates[:, :, :2])
      assert torch.all(
          result_box_coordinates[:, :, :2] < 0.07
      )  # 0.07 = (1.14 - 1) / 2
      assert torch.all(1 - 0.07 < result_box_coordinates[:, :, 2:])
      assert torch.all(result_box_coordinates[:, :, 2:] < 1)
  
      # Since the bounding box was aligned with the right and left edges of the image, we should observe 0 values in the
      # right and left edges of the cropped image, as a result of expansion
      assert torch.all(result_video[0, 0, 0, :, 0] == 0)
      assert torch.all(result_video[0, 0, 0, :, -1] == 0)
      # but not on the top and bottom edges
      assert torch.all(result_video[0, 0, 0, 0, 1:-1] > 0)
      assert torch.all(result_video[0, 0, 0, -1, 1:-1] > 0)
  
      # check the values of two cropped pixels created earlier by `video[0, 0, 0, :, :] = x + y`
      assert 70 <= result_video[0, 0, 0, 1, 1].item() <= 80
      assert 90 <= result_video[0, 0, 0, -2, -2].item() <= 100
  
file_path: ml-cvnets/tests/transforms/test_video.py
imports: import operator
  import os
  from pathlib import Path
  from typing import Dict, Tuple
  import pytest
  import torch
  from data.transforms.video import CropByBoundingBox, SaveInputs, ShuffleAudios, _resize_fn
  from data.video_reader.pyav_reader import PyAVReader
  from tests.configs import get_config
label_desc: Use image node_id 2 for calling a global function with example usage: test_crop_by_bounding_box() without return types