code: def test_joblib_cache(tmp_path):
      """Test using joblib cache."""
      from joblib import Memory, hash
  
      mask = np.zeros((40, 40, 40))
      mask[20, 20, 20] = 1
      mask_img = nibabel.Nifti1Image(mask, np.eye(4))
  
      filename = testing.write_imgs_to_path(
          mask_img,
          file_path=tmp_path,
          create_files=True,
      )
      masker = NiftiMasker(mask_img=filename)
      masker.fit()
      mask_hash = hash(masker.mask_img_)
      get_data(masker.mask_img_)
      assert mask_hash == hash(masker.mask_img_)
  
      # Test a tricky issue with memmapped joblib.memory that makes
      # imgs return by inverse_transform impossible to save
      cachedir = mkdtemp()
      try:
          masker.memory = Memory(
              location=cachedir, mmap_mode="r", verbose=0
          )
          X = masker.transform(mask_img)
          # inverse_transform a first time, so that the result is cached
          out_img = masker.inverse_transform(X)
          out_img = masker.inverse_transform(X)
          out_img.to_filename(os.path.join(cachedir, "test.nii"))
      finally:
          # enables to delete "filename" on windows
          del masker
          shutil.rmtree(cachedir, ignore_errors=True)
  
imports: import os
  import shutil
  import warnings
  from tempfile import mkdtemp
  import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from nilearn._utils import data_gen, exceptions, testing
  from nilearn._utils.class_inspect import get_params
  from nilearn.image import get_data, index_img
  from nilearn.maskers import NiftiMasker
  from nilearn.maskers.nifti_masker import _filter_and_mask
label_desc: Use image node_id 15 for calling a global function with example usage: test_joblib_cache(tmp_path) without return types