code: def test_cache_limit():
      def cache_size():
          return sum(len(v) for v in parser_cache.values())
  
      try:
          parser_cache.clear()
          future_node_cache_item = _NodeCacheItem(
              "bla", [], change_time=time.time() + 10e6
          )
          old_node_cache_item = _NodeCacheItem(
              "bla", [], change_time=time.time() - 10e4
          )
          parser_cache["some_hash_old"] = {
              "/path/%s" % i: old_node_cache_item for i in range(300)
          }
          parser_cache["some_hash_new"] = {
              "/path/%s" % i: future_node_cache_item for i in range(300)
          }
          assert cache_size() == 600
          parse("somecode", cache=True, path="/path/somepath")
          assert cache_size() == 301
      finally:
          parser_cache.clear()
  
imports: import os
  import pytest
  import time
  from pathlib import Path
  from parso.cache import _CACHED_FILE_MAXIMUM_SURVIVAL, _VERSION_TAG, _get_cache_clear_lock_path, _get_hashed_path, _load_from_file_system, _NodeCacheItem, _remove_cache_and_update_lock, _save_to_file_system, load_module, parser_cache, try_to_save_module
  from parso._compatibility import is_pypy
  from parso import load_grammar
  from parso import cache
  from parso import file_io
  from parso import parse
label_desc: Use image node_id 5 for calling a global function with example usage: test_cache_limit() and returns: sum