class_docstr: Represents a persisted graph component in the graph.
  
  Attributes:
      name: The unique identifier for the `Resource`. Used to locate the associated
          data from a `ModelStorage`. Normally matches the name of the node which
          created it.
      output_fingerprint: An unique identifier for a specific instantiation of a
          `Resource`. Used to distinguish a specific persistence for the same
          `Resource` when saving to the cache.
class_docstr_tok: ["Represents","a","persisted","graph","component","in","the","graph",".","Attributes",":","name",":","The","unique","identifier","for","the","`","Resource","`",".","Used","to","locate","the","associated","data","from","a","`","ModelStorage","`",".","Normally","matches","the","name","of","the","node","which","created","it",".","output_fingerprint",":","An","unique","identifier","for","a","specific","instantiation","of","a","`","Resource","`",".","Used","to","distinguish","a","specific","persistence","for","the","same","`","Resource","`","when","saving","to","the","cache","."]
docstr: Loads a `Resource` from the cache.
  
  This automatically loads the persisted resource into the given `ModelStorage`.
  
  Args:
      node_name: The node name of the `Resource`.
      directory: The directory with the cached `Resource`.
      model_storage: The `ModelStorage` which the cached `Resource` will be added
          to so that the `Resource` is accessible for other graph nodes.
      output_fingerprint: The fingerprint of the cached `Resource`.
  
  Returns:
      The ready-to-use and accessible `Resource`.
docstr_tok: ["Loads","a","`","Resource","`","from","the","cache",".","This","automatically","loads","the","persisted","resource","into","the","given","`","ModelStorage","`",".","Args",":","node_name",":","The","node","name","of","the","`","Resource","`",".","directory",":","The","directory","with","the","cached","`","Resource","`",".","model_storage",":","The","`","ModelStorage","`","which","the","cached","`","Resource","`","will","be","added","to","so","that","the","`","Resource","`","is","accessible","for","other","graph","nodes",".","output_fingerprint",":","The","fingerprint","of","the","cached","`","Resource","`",".","Returns",":","The","ready-to-use","and","accessible","`","Resource","`","."]
code: def from_cache(
      cls,
      node_name: Text,
      directory: Path,
      model_storage: ModelStorage,
      output_fingerprint: Text,
  ) -> Resource:
      """Loads a `Resource` from the cache.
  
      This automatically loads the persisted resource into the given `ModelStorage`.
  
      Args:
          node_name: The node name of the `Resource`.
          directory: The directory with the cached `Resource`.
          model_storage: The `ModelStorage` which the cached `Resource` will be added
              to so that the `Resource` is accessible for other graph nodes.
          output_fingerprint: The fingerprint of the cached `Resource`.
  
      Returns:
          The ready-to-use and accessible `Resource`.
      """
      logger.debug(f"Loading resource '{node_name}' from cache.")
  
      resource = Resource(
          node_name, output_fingerprint=output_fingerprint
      )
      if not any(directory.glob("*")):
          logger.debug(f"Cached resource for '{node_name}' was empty.")
          return resource
  
      try:
          with model_storage.write_to(resource) as resource_directory:
              rasa.utils.common.copy_directory(
                  directory, resource_directory
              )
      except ValueError:
          # This might happen during finetuning as in this case the model storage
          # is already filled
          if not rasa.utils.io.are_directories_equal(
              directory, resource_directory
          ):
              # We skip caching in case we see the cached output and output
              # from the model which we want to finetune are not the same
              raise
  
      logger.debug(
          f"Successfully initialized resource '{node_name}' from cache."
      )
  
      return resource
  
file_path: rasa/rasa/engine/storage/resource.py
imports: from __future__ import annotations
  import logging
  import typing
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import Text
  import uuid
  import rasa.utils.common
  import rasa.utils.io
label_desc: Use image node_id 1 for calling the Resource obj's underlying member method code with example usage: obj.from_cache(cls, node_name, directory, model_storage, output_fingerprint) and returns: resource, resource