code: def test_dict():
      i = Interval(1, 2, "y", canvas_height=5)
      i_dict = {
          "block_type": "interval",
          "start": 1,
          "end": 2,
          "axis": "y",
          "canvas_height": 5,
          "canvas_width": 0,
      }
      assert i.to_dict() == i_dict
      assert i == Interval.from_dict(i_dict)
  
      r = Rectangle(1, 2, 3, 4)
      r_dict = {
          "block_type": "rectangle",
          "x_1": 1,
          "y_1": 2,
          "x_2": 3,
          "y_2": 4,
      }
      assert r.to_dict() == r_dict
      assert r == Rectangle.from_dict(r_dict)
  
      q = Quadrilateral(np.arange(8).reshape(4, 2), 200, 400)
      q_dict = {
          "block_type": "quadrilateral",
          "points": [0, 1, 2, 3, 4, 5, 6, 7],
          "height": 200,
          "width": 400,
      }
      assert q.to_dict() == q_dict
      assert q == Quadrilateral.from_dict(q_dict)
  
      l = Layout([i, r, q], page_data={"width": 200, "height": 200})
      l_dict = {
          "page_data": {"width": 200, "height": 200},
          "blocks": [i_dict, r_dict, q_dict],
      }
      assert l.to_dict() == l_dict
  
      i2 = TextBlock(i, "")
      i_dict["text"] = ""
      assert i2.to_dict() == i_dict
      assert i2 == TextBlock.from_dict(i_dict)
  
      r2 = TextBlock(r, id=24)
      r_dict["id"] = 24
      assert r2.to_dict() == r_dict
      assert r2 == TextBlock.from_dict(r_dict)
  
      q2 = TextBlock(q, text="test", parent=45)
      q_dict["text"] = "test"
      q_dict["parent"] = 45
      assert q2.to_dict() == q_dict
      assert q2 == TextBlock.from_dict(q_dict)
  
      l2 = Layout([i2, r2, q2])
      l2_dict = {"page_data": {}, "blocks": [i_dict, r_dict, q_dict]}
      assert l2.to_dict() == l2_dict
  
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 11 for calling a global function with example usage: test_dict() without return types