code: def test_cache_memory_level(tmp_path):
      joblib_dir = (
          tmp_path
          / "joblib"
          / "nilearn"
          / "_utils"
          / "tests"
          / "test_cache_mixin"
          / "f"
      )
  
      cache_mixin.cache(f, Memory(location=None))(2)
      assert len(_get_subdirs(joblib_dir)) == 0
  
      mem = Memory(location=str(tmp_path), verbose=0)
  
      cache_mixin.cache(f, mem, func_memory_level=2, memory_level=1)(2)
      assert len(_get_subdirs(joblib_dir)) == 0
  
      cache_mixin.cache(f, mem, func_memory_level=2, memory_level=3)(2)
      assert len(_get_subdirs(joblib_dir)) == 1
  
      cache_mixin.cache(f, mem)(3)
      assert len(_get_subdirs(joblib_dir)) == 2
  
file_path: nilearn/nilearn/_utils/tests/test_cache_mixin.py
imports: import os
  import shutil
  from pathlib import Path
  import pytest
  from joblib import Memory
  import nilearn
  from nilearn._utils import CacheMixin, cache_mixin
label_desc: Use image node_id 7 for calling a global function with example usage: test_cache_memory_level(tmp_path) without return types