code: def read_json(
      file, output_type="Figure", skip_invalid=False, engine=None
  ):
      """
      Construct a figure from the JSON contents of a local file or readable
      Python object
  
      Parameters
      ----------
      file: str or readable
         A string containing the path to a local file or a read-able Python
         object (e.g. a pathlib.Path object or an open file descriptor)
  
      output_type: type or str (default 'Figure')
          The output figure type or type name.
          One of:  graph_objs.Figure, 'Figure', graph_objs.FigureWidget, 'FigureWidget'
  
      skip_invalid: bool (default False)
          False if invalid figure properties should result in an exception.
          True if invalid figure properties should be silently ignored.
  
      engine: str (default None)
          The JSON decoding engine to use. One of:
            - if "json", parse JSON using built in json module
            - if "orjson", parse using the faster orjson module, requires the orjson
              package
            - if "auto" use orjson module if available, otherwise use the json module
  
          If not specified, the default engine is set to the current value of
          plotly.io.json.config.default_engine.
  
      Returns
      -------
      Figure or FigureWidget
      """
  
      # Try to cast `file` as a pathlib object `path`.
      # -------------------------
      # ----------------------------------------------
      file_is_str = isinstance(file, str)
      if isinstance(file, str):
          # Use the standard Path constructor to make a pathlib object.
          path = Path(file)
      elif isinstance(file, Path):
          # `file` is already a Path object.
          path = file
      else:
          # We could not make a Path object out of file. Either `file` is an open file
          # descriptor with a `write()` method or it's an invalid object.
          path = None
  
      # Read file contents into JSON string
      # -----------------------------------
      if path is not None:
          json_str = path.read_text()
      else:
          json_str = file.read()
  
      # Construct and return figure
      # ---------------------------
      return from_json(
          json_str,
          skip_invalid=skip_invalid,
          output_type=output_type,
          engine=engine,
      )
  
imports: import json
  import decimal
  import datetime
  import warnings
  from pathlib import Path
  from plotly.io._utils import validate_coerce_fig_to_dict, validate_coerce_output_type
  from _plotly_utils.optional_imports import get_module
  from _plotly_utils.basevalidators import ImageUriValidator
label_desc: Use image node_id 8 for calling a global function with example usage: read_json(file, output_type, skip_invalid, engine) and returns: from_json