code: def load_dict(
      data: Union[Dict, List[Dict]]
  ) -> Union[BaseLayoutElement, Layout]:
      """Load a dict of list of dict representations of some layout data,
      automatically parse its type, and save it as any of BaseLayoutElement
      or Layout datatype.
  
      Args:
          data (Union[Dict, List]):
              A dict of list of dict representations of the layout data
  
      Raises:
          ValueError:
              If the data format is incompatible with the layout-data-JSON format,
              raise a `ValueError`.
          ValueError:
              If any `block_type` name is not in the available list of layout element
              names defined in `BASECOORD_ELEMENT_NAMEMAP`, raise a `ValueError`.
  
      Returns:
          Union[BaseLayoutElement, Layout]:
              Based on the dict format, it will automatically parse the type of
              the data and load it accordingly.
      """
      if isinstance(data, dict):
          if "page_data" in data:
              # It is a layout instance
              return Layout(
                  load_dict(data["blocks"])._blocks,
                  page_data=data["page_data"],
              )
          else:
              if data["block_type"] not in BASECOORD_ELEMENT_NAMEMAP:
                  raise ValueError(
                      f"Invalid block_type {data['block_type']}"
                  )
  
              # Check if it is a textblock
              is_textblock = any(
                  ele in data for ele in TextBlock._features
              )
              if is_textblock:
                  return TextBlock.from_dict(data)
              else:
                  return BASECOORD_ELEMENT_NAMEMAP[
                      data["block_type"]
                  ].from_dict(data)
  
      elif isinstance(data, list):
          return Layout([load_dict(ele) for ele in data])
  
      else:
          raise ValueError(f"Invalid input JSON structure.")
  
file_path: layout-parser/src/layoutparser/io/basic.py
imports: import ast
  import json
  from typing import List, Union, Dict, Dict, Any
  import pandas
  from ..elements import BaseLayoutElement, TextBlock, Layout, BASECOORD_ELEMENT_NAMEMAP
label_desc: Use image node_id 2 for calling a global function with example usage: load_dict(data) and returns: Layout, Layout, TextBlock, BASECOORD_ELEMENT_NAMEMAP