code: def load(filename: FileSpec, **kwargs) -> FileBasedImage:
      r"""Load file given filename, guessing at file type
  
      Parameters
      ----------
      filename : str or os.PathLike
         specification of file to load
      \*\*kwargs : keyword arguments
          Keyword arguments to format-specific load
  
      Returns
      -------
      img : ``SpatialImage``
         Image of guessed type
      """
      filename = _stringify_path(filename)
  
      # Check file exists and is not empty
      try:
          stat_result = os.stat(filename)
      except OSError:
          raise FileNotFoundError(
              f"No such file or no access: '{filename}'"
          )
      if stat_result.st_size <= 0:
          raise ImageFileError(f"Empty file: '{filename}'")
  
      sniff = None
      for image_klass in all_image_classes:
          is_valid, sniff = image_klass.path_maybe_image(
              filename, sniff
          )
          if is_valid:
              img = image_klass.from_filename(filename, **kwargs)
              return img
  
      matches, msg = _signature_matches_extension(filename)
      if not matches:
          raise ImageFileError(msg)
  
      raise ImageFileError(f'Cannot work out file type of "{filename}"')
  
file_path: nibabel/nibabel/loadsave.py
imports: from __future__ import annotations
  import os
  import typing
  import numpy
  from .arrayproxy import is_proxy
  from .deprecated import deprecate_with_version
  from .filebasedimages import ImageFileError
  from .filename_parser import _stringify_path, splitext_addext
  from .imageclasses import all_image_classes
  from .openers import ImageOpener
label_desc: Use image node_id 2 for calling a global function with example usage: load(filename) and returns: img