code: def read(file_or_stream, fmt, as_version=4, **kwargs):
      
      fmt = long_form_one_format(fmt)
      if fmt['extension'] == '.ipynb':
          notebook = nbformat.read(file_or_stream, as_version, **kwargs)
          rearrange_jupytext_metadata(notebook.metadata)
          return notebook
  
      return reads(file_or_stream.read(), fmt, **kwargs)
docs: Read a notebook from a file