code: def test_shape_operations():
      i_1 = Interval(1, 2, axis="y", canvas_height=30, canvas_width=400)
      i_2 = TextBlock(Interval(1, 2, axis="x"))
      i_3 = Interval(1, 2, axis="y")
  
      r_1 = Rectangle(0.5, 0.5, 2.5, 1.5)
      r_2 = TextBlock(Rectangle(0.5, 0.5, 2, 2.5))
  
      q_1 = Quadrilateral([[1, 1], [2.5, 1.2], [2.5, 3], [1.5, 3]])
      q_2 = TextBlock(
          Quadrilateral([[0.5, 0.5], [2, 1], [1.5, 2.5], [0.5, 2]])
      )
  
      # I and I in different axes
      assert i_1.intersect(i_1) == i_1
      assert i_1.intersect(i_2) == Rectangle(1, 1, 2, 2)
      assert (
          i_1.intersect(i_3) == i_1
      )  # Ensure intersect copy the canvas size
  
      assert i_1.union(i_1) == i_1
      with pytest.raises(InvalidShapeError):
          assert i_1.union(i_2) == Rectangle(1, 1, 2, 2)
  
      # I and R in different axes
      assert i_1.intersect(r_1) == Rectangle(0.5, 1, 2.5, 1.5)
      assert i_2.intersect(r_1).block == Rectangle(1, 0.5, 2, 1.5)
      assert i_1.union(r_1) == Rectangle(0.5, 0.5, 2.5, 2)
      assert i_2.union(r_1).block == r_1
  
      # I and Q in strict mode
      with pytest.raises(NotSupportedShapeError):
          i_1.intersect(q_1)
          i_1.union(q_1)
  
      # I and Q in different axes
      assert i_1.intersect(q_1, strict=False) == Rectangle(1, 1, 2.5, 2)
      assert i_1.union(q_1, strict=False) == Rectangle(1, 1, 2.5, 3)
      assert i_2.intersect(q_1, strict=False).block == Rectangle(
          1, 1, 2, 3
      )
      assert i_2.union(q_1, strict=False).block == Rectangle(
          1, 1, 2.5, 3
      )
  
      # R and I
      assert r_1.intersect(i_1) == i_1.intersect(r_1)
  
      # R and R
      assert (
          r_1.intersect(r_2)
          == r_2.intersect(r_1).block
          == Rectangle(0.5, 0.5, 2, 1.5)
      )
      assert (
          r_1.union(r_2)
          == r_2.union(r_1).block
          == Rectangle(0.5, 0.5, 2.5, 2.5)
      )
  
      # R and Q
      with pytest.raises(NotSupportedShapeError):
          r_1.intersect(q_1)
          r_1.union(q_1)
  
      assert r_1.intersect(q_1, strict=False) == Rectangle(
          1, 1, 2.5, 1.5
      )
      assert r_1.union(q_1, strict=False) == Rectangle(0.5, 0.5, 2.5, 3)
      assert r_1.intersect(q_2, strict=False) == r_1.intersect(
          q_2.to_rectangle()
      )
      assert r_1.union(q_2, strict=False) == r_1.union(
          q_2.to_rectangle()
      )
  
      # Q and others in strict mode
      with pytest.raises(NotSupportedShapeError):
          q_1.intersect(i_1)
          q_1.intersect(r_1)
          q_1.intersect(q_2)
  
      # Q and I
      assert q_1.intersect(i_1, strict=False) == i_1.intersect(
          q_1, strict=False
      )
      assert q_1.union(i_1, strict=False) == i_1.union(
          q_1, strict=False
      )
  
      # Q and R
      assert q_1.intersect(r_1, strict=False) == r_1.intersect(
          q_1, strict=False
      )
      assert q_1.union(r_1, strict=False) == r_1.union(
          q_1, strict=False
      )
  
      # Q and R
      assert (
          q_1.intersect(q_2, strict=False)
          == q_2.intersect(q_1, strict=False).block
      )
      assert q_1.intersect(q_2, strict=False) == Rectangle(1, 1, 2, 2.5)
      assert (
          q_1.union(q_2, strict=False)
          == q_2.union(q_1, strict=False).block
      )
      assert q_1.union(q_2, strict=False) == Rectangle(0.5, 0.5, 2.5, 3)
  
file_path: layout-parser/tests/test_elements.py
imports: import pytest
  import numpy
  import pandas
  from layoutparser.elements import Interval, Rectangle, Quadrilateral, TextBlock, Layout
  from layoutparser.elements.errors import InvalidShapeError, NotSupportedShapeError
label_desc: Use image node_id 10 for calling a global function with example usage: test_shape_operations() without return types