code: def test_resource_caching_if_already_restored(
      tmp_path_factory: TempPathFactory,
  ):
      initial_storage_dir = tmp_path_factory.mktemp(
          "initial_model_storage"
      )
      model_storage = LocalModelStorage(initial_storage_dir)
  
      resource = Resource("my resource")
  
      # Fill model storage
      test_filename = "file.txt"
      test_content = "test_resource_caching"
      with model_storage.write_to(resource) as temporary_directory:
          file = temporary_directory / test_filename
          file.write_text(test_content)
  
      cache_dir = tmp_path_factory.mktemp("cache_dir")
  
      # Cache resource
      resource.to_cache(cache_dir, model_storage)
  
      new_storage_dir = tmp_path_factory.mktemp("new dir")
      rasa.utils.common.copy_directory(
          initial_storage_dir, new_storage_dir
      )
  
      reinstantiated_resource = Resource.from_cache(
          resource.name,
          cache_dir,
          LocalModelStorage(new_storage_dir),
          resource.output_fingerprint,
      )
  
      assert reinstantiated_resource == resource
  
file_path: rasa/tests/engine/storage/test_resource.py
imports: from pathlib import Path
  import pytest
  from _pytest.tmpdir import TempPathFactory
  import rasa.utils.common
  from rasa.engine.storage.local_model_storage import LocalModelStorage
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
label_desc: Use image node_id 2 for calling a global function with example usage: test_resource_caching_if_already_restored(tmp_path_factory) without return types