code: def file_or_url_context(resource_name):
      """Yield name of file from the given resource (i.e. file or url)."""
      if is_url(resource_name):
          url_components = urllib.parse.urlparse(resource_name)
          _, ext = os.path.splitext(url_components.path)
          try:
              with tempfile.NamedTemporaryFile(
                  delete=False, suffix=ext
              ) as f:
                  with urllib.request.urlopen(resource_name) as u:
                      f.write(u.read())
              # f must be closed before yielding
              yield f.name
          except (URLError, HTTPError):
              # could not open URL
              os.remove(f.name)
              raise
          except (
              FileNotFoundError,
              FileExistsError,
              PermissionError,
              BaseException,
          ):
              # could not create temporary file
              raise
          else:
              os.remove(f.name)
      else:
          yield resource_name
  
file_path: scikit-image/skimage/io/util.py
imports: import urllib.parse
  import urllib.request
  from urllib.error import URLError, HTTPError
  import os
  import re
  import tempfile
  from contextlib import contextmanager
label_desc: Use image node_id 2 for calling a global function with example usage: file_or_url_context(resource_name) without return types