code: def test_simple_profiler_memory_caching():
      """A test case simulating memory caching for SimpleProfiler"""
      model_library = ModelLibrary(
          models=[ModelA, ModelB, ModelC, ModelD, Pipeline2]
      )
      pipeline = model_library.get("pipeline2")
      item = {"abc": 123}
      profiler = SimpleProfiler(pipeline)
      _ = pipeline.predict(item)
      stat = profiler.summary()
  
      assert set(stat["Name"]) == set(
          ["pipeline2", "model_b", "model_a", "model_c", "model_d"]
      )
  
      # test graph dependencies
      graph = profiler.graph
      assert graph["model_a"] == set()
      assert graph["model_b"] == set(["model_a"])
      assert graph["model_c"] == set()
      assert graph["model_d"] == set(["model_a"])
      assert graph["pipeline2"] == set(
          ["model_a", "model_b", "model_c", "model_d"]
      )
  
      # test graph calls
      graph_calls = profiler.graph_calls
      assert graph_calls["model_a"] == {"__main__": 3}
      assert graph_calls["model_b"] == {"__main__": 1, "model_a": 1}
      assert graph_calls["model_c"] == {"__main__": 1}
      assert graph_calls["model_d"] == {"__main__": 1, "model_a": 1}
      assert graph_calls["pipeline2"] == {
          "__main__": 1,
          "model_a": 3,
          "model_b": 1,
          "model_c": 1,
          "model_d": 1,
      }
  
      # test number of call
      num_call = dict(zip(stat["Name"], stat["Num call"]))
      assert num_call == {
          "pipeline2": 1,
          "model_a": 3,
          "model_b": 1,
          "model_d": 1,
          "model_c": 1,
      }
  
      # test net percentage ()
      assert math.isclose(
          sum(stat["Net percentage %"]), 100, abs_tol=1.0
      )
  
      # test total percentage ~= 100% (decreasing)
      assert math.isclose(
          stat["Total percentage %"][0], 99.9, abs_tol=1.0
      )
  
      # test print table
      table_str = profiler.summary(print_table=True)
      assert isinstance(table_str, str)
  
imports: import math
  import time
  from typing import Any, Dict
  import pytest
  from modelkit.core import ModelLibrary
  from modelkit.core.model import Model
  from modelkit.core.profilers.simple import SimpleProfiler
label_desc: Use image node_id 7 for calling a global function with example usage: test_simple_profiler_memory_caching() without return types