code: def tmp_userdir(tmp_path):
      ud = tmp_path / "userdir"
      ud.mkdir(exist_ok=True)
  
      if sys.platform.startswith("win"):
          user_dir_env = "LOCALAPPDATA"
      else:
          user_dir_env = "IMAGEIO_USERDIR"
  
      old_user_dir = os.getenv(user_dir_env, None)
      os.environ[user_dir_env] = str(ud)
  
      yield ud
  
      if old_user_dir is not None:
          os.environ[user_dir_env] = old_user_dir
      else:
          del os.environ[user_dir_env]
  
file_path: imageio/tests/conftest.py
imports: import contextlib
  import os
  import shutil
  import sys
  import warnings
  from functools import wraps
  from pathlib import Path
  import pytest
  import imageio
label_desc: Use image node_id 8 for calling a global function with example usage: tmp_userdir(tmp_path) without return types