code: def setup_library(tmp_path_factory, vendored_lib):
      # Checks if freeimage is installed by the system
      from imageio.plugins.freeimage import fi
  
      use_imageio_binary = not fi.has_lib()
  
      # During this test, pretend that FI is the default format
      with warnings.catch_warnings(record=True):
          iio.formats.sort("-FI")
  
      if use_imageio_binary:
          if sys.platform.startswith("win"):
              user_dir_env = "LOCALAPPDATA"
          else:
              user_dir_env = "IMAGEIO_USERDIR"
  
          # Setup from test_images/freeimage
          ud = tmp_path_factory.mktemp("userdir")
          old_user_dir = os.getenv(user_dir_env, None)
          os.environ[user_dir_env] = str(ud)
          os.makedirs(ud, exist_ok=True)
  
          add = core.appdata_dir("imageio")
          os.makedirs(add, exist_ok=True)
          shutil.copytree(vendored_lib, os.path.join(add, "freeimage"))
          fi.load_freeimage()
          assert (
              fi.has_lib()
          ), "imageio-binaries' version of libfreeimage was not found"
  
      yield
  
      if use_imageio_binary:
          if old_user_dir is not None:
              os.environ[user_dir_env] = old_user_dir
          else:
              del os.environ[user_dir_env]
  
      # Sort formats back to normal
      with warnings.catch_warnings(record=True):
          iio.formats.sort()
  
imports: import os
  import shutil
  import sys
  import platform
  import warnings
  import fsspec
  import imageio.plugins
  import imageio.v3
  import imageio.v2
  import numpy
  import pytest
  from imageio import core
  from imageio.core import IS_PYPY
  from pytest import raises
  from conftest import deprecated_test
label_desc: Use image node_id 2 for calling a global function with example usage: setup_library(tmp_path_factory, vendored_lib) without return types