code: def test_iou():
      iou = get_distance_by_name("iou")
  
      # perfect match
      det = np.array([[0, 0, 1, 1]])
      obj = np.array([[0, 0, 1, 1]])
      np.testing.assert_almost_equal(iou.distance_function(det, obj), 0)
  
      # float type
      det = np.array([[0.0, 0.0, 1.1, 1.1]])
      obj = np.array([[0.0, 0.0, 1.1, 1.1]])
      np.testing.assert_almost_equal(iou.distance_function(det, obj), 0)
  
      # det contained in obj
      det = np.array([[0, 0, 1, 1]])
      obj = np.array([[0, 0, 2, 2]])
      np.testing.assert_almost_equal(
          iou.distance_function(det, obj), 1 - 1 / 4
      )
  
      # no overlap
      det = np.array([[0, 0, 1, 1]])
      obj = np.array([[1, 1, 2, 2]])
      np.testing.assert_almost_equal(iou.distance_function(det, obj), 1)
  
      # obj fully contained on det
      det = np.array([[0, 0, 4, 4]])
      obj = np.array([[1, 1, 2, 2]])
      np.testing.assert_almost_equal(
          iou.distance_function(det, obj), 1 - 1 / 16
      )
  
      # partial overlap
      det = np.array([[0, 0, 2, 2]])
      obj = np.array([[1, 1, 3, 3]])
      np.testing.assert_almost_equal(
          iou.distance_function(det, obj), 1 - 1 / (8 - 1)
      )
  
      # invalid bbox
      det = np.array([[0, 0]])
      obj = np.array([[0, 0]])
      with pytest.raises(AssertionError):
          iou.distance_function(det, obj)
  
      # invalid bbox
      det = np.array([[0, 0, 1, 1, 2, 2]])
      obj = np.array([[0, 0, 2, 2]])
      with pytest.raises(AssertionError):
          iou.distance_function(det, obj)
  
file_path: norfair/tests/test_distances.py
imports: import numpy
  import pytest
  from norfair.distances import ScalarDistance, ScipyDistance, VectorizedDistance, create_keypoints_voting_distance, create_normalized_mean_euclidean_distance, frobenius, get_distance_by_name
label_desc: Use image node_id 4 for calling a global function with example usage: test_iou() without return types