code: def test_custom_lru_cache():
      """Test our _custom_lru_cache implementation."""
      n_calls = [0, 0]
      start_size = len(_LRU_CACHES)
  
      @_custom_lru_cache(2)
      def my_fun(*args):
          n_calls[0] += 1
          return ", ".join(arg.__class__.__name__ for arg in args)
  
      assert len(_LRU_CACHES) == start_size + 1
      fun_hash = list(_LRU_CACHES)[-1]
      assert _LRU_CACHE_MAXSIZES[fun_hash] == 2
  
      @_custom_lru_cache(1)
      def my_fun_2(*args):
          n_calls[1] += 1
          return ", ".join(arg.__class__.__name__ for arg in args)
  
      assert len(_LRU_CACHES) == start_size + 2
      fun_2_hash = list(_LRU_CACHES)[-1]
      assert _LRU_CACHE_MAXSIZES[fun_2_hash] == 1
  
      assert n_calls == [0, 0]
      assert my_fun(1, 2, 3) == "int, int, int"
      assert n_calls == [1, 0]
      assert my_fun_2(1, 2, 3.0) == "int, int, float"
      assert n_calls == [1, 1]
      # repeated calls use cached version
      assert my_fun(1, 2, 3) == "int, int, int"
      assert n_calls == [1, 1]
      assert my_fun_2(1, 2, 3.0) == "int, int, float"
      assert n_calls == [1, 1]
      assert len(_LRU_CACHES[fun_hash]) == 1
      assert len(_LRU_CACHES[fun_2_hash]) == 1
      assert my_fun(1, np.array([2]), 3) == "int, ndarray, int"
      assert n_calls == [2, 1]
      assert len(_LRU_CACHES[fun_hash]) == 2
      assert (
          my_fun_2(1, sparse.eye(1, format="csc")) == "int, csc_matrix"
      )
      assert n_calls == [2, 2]
      assert len(_LRU_CACHES[fun_2_hash]) == 1  # other got popped
      # we could add support for this eventually, but don't bother for now
      with pytest.raises(RuntimeError, match="Unsupported sparse type"):
          my_fun_2(1, sparse.eye(1, format="coo"))
      assert n_calls == [2, 2]
  
imports: from copy import deepcopy
  from datetime import datetime, timezone
  from io import StringIO
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from mne import pick_types, read_cov, read_evokeds
  from mne._fiff.pick import _picks_by_type
  from mne.epochs import make_fixed_length_epochs
  from mne.io import read_raw_fif
  from mne.time_frequency import tfr_morlet
  from mne.utils import _PCA, _apply_scaling_array, _apply_scaling_cov, _array_equal_nan, _cal_to_julian, _custom_lru_cache, _dt_to_julian, _freq_mask, _get_inst_data, _julian_to_cal, _julian_to_dt, _reg_pinv, _ReuseCycle, _time_mask, _undo_scaling_array, _undo_scaling_cov, compute_corr, create_slices, grand_average, hashfunc, numerics, object_diff, object_hash, object_size, random_permutation, sum_squared
  from mne.utils.numerics import _LRU_CACHE_MAXSIZES, _LRU_CACHES
label_desc: Use image node_id 21 for calling a global function with example usage: test_custom_lru_cache() and returns: str, str