code: def _filefind(
      filename: str, path_dirs: str | Sequence[str] | None = None
  ) -> str:
      """Find a file by looking through a sequence of paths.
  
      This iterates through a sequence of paths looking for a file and returns
      the full, absolute path of the first occurrence of the file.  If no set of
      path dirs is given, the filename is tested as is, after running through
      :func:`expandvars` and :func:`expanduser`.  Thus a simple call::
  
          filefind('myfile.txt')
  
      will find the file in the current working dir, but::
  
          filefind('~/myfile.txt')
  
      Will find the file in the users home directory.  This function does not
      automatically try any paths, such as the cwd or the user's home directory.
  
      Parameters
      ----------
      filename : str
          The filename to look for.
      path_dirs : str, None or sequence of str
          The sequence of paths to look for the file in.  If None, the filename
          need to be absolute or be in the cwd.  If a string, the string is
          put into a sequence and the searched.  If a sequence, walk through
          each element and join with ``filename``, calling :func:`expandvars`
          and :func:`expanduser` before testing for existence.
  
      Returns
      -------
      Raises :exc:`IOError` or returns absolute path to file.
      """
  
      # If paths are quoted, abspath gets confused, strip them...
      filename = filename.strip('"').strip("'")
      # If the input is an absolute path, just check it exists
      if os.path.isabs(filename) and os.path.isfile(filename):
          return filename
  
      if path_dirs is None:
          path_dirs = ("",)
      elif isinstance(path_dirs, str):
          path_dirs = (path_dirs,)
  
      for path in path_dirs:
          if path == ".":
              path = os.getcwd()  # noqa
          testname = _expand_path(os.path.join(path, filename))
          if os.path.isfile(testname):
              return os.path.abspath(testname)
      msg = f"File {filename!r} does not exist in any of the search paths: {path_dirs!r}"
      raise OSError(msg)
  
imports: from __future__ import annotations
  import os
  from typing import Sequence
  from jupyter_core.utils import ensure_async, run_sync
  from .session import utcnow
label_desc: Use image node_id 1 for calling a global function with example usage: _filefind(filename, path_dirs) and returns: filename, os