code: def read(fp, as_version, capture_validation_error=None, **kwargs):
      """Read a notebook from a file as a NotebookNode of the given version.
  
      The string can contain a notebook of any version.
      The notebook will be returned `as_version`, converting, if necessary.
  
      Notebook format errors will be logged.
  
      Parameters
      ----------
      fp : file or str
          A file-like object with a read method that returns unicode (use
          ``io.open()`` in Python 2), or a path to a file.
      as_version : int
          The version of the notebook format to return.
          The notebook will be converted, if necessary.
          Pass nbformat.NO_CONVERT to prevent conversion.
      capture_validation_error : dict, optional
          If provided, a key of "ValidationError" with a
          value of the ValidationError instance will be added
          to the dictionary.
  
      Returns
      -------
      nb : NotebookNode
          The notebook that was read.
      """
  
      try:
          buf = fp.read()
      except AttributeError:
          with open(fp, encoding="utf8") as f:  # noqa: PTH123
              return reads(
                  f.read(),
                  as_version,
                  capture_validation_error,
                  **kwargs,
              )
  
      return reads(buf, as_version, capture_validation_error, **kwargs)
  
file_path: nbformat/nbformat/__init__.py
imports: from __future__ import annotations
  from pathlib import Path
  from traitlets.log import get_logger
  from .None import v1, v2, v3, v4
  from ._version import __version__, version_info
  from .sentinel import Sentinel
  from .None import reader
  from .converter import convert
  from .notebooknode import NotebookNode, from_dict
  from .v4 import nbformat
  from .v4 import nbformat_minor
  from .validator import ValidationError, validate
label_desc: Use image node_id 3 for calling a global function with example usage: read(fp, as_version, capture_validation_error) and returns: reads, reads