class_docstr: Instantiates and runs a `GraphComponent` within a graph.
  
  A `GraphNode` is a wrapper for a `GraphComponent` that allows it to be executed
  in the context of a graph. It is responsible for instantiating the component at the
  correct time, collecting the inputs from the parent nodes, running the run function
  of the component and passing the output onwards.
class_docstr_tok: ["Instantiates","and","runs","a","`","GraphComponent","`","within","a","graph",".","A","`","GraphNode","`","is","a","wrapper","for","a","`","GraphComponent","`","that","allows","it","to","be","executed","in","the","context","of","a","graph",".","It","is","responsible","for","instantiating","the","component","at","the","correct","time",",","collecting","the","inputs","from","the","parent","nodes",",","running","the","run","function","of","the","component","and","passing","the","output","onwards","."]
code: def _get_resource(self, kwargs: Dict[Text, Any]) -> Resource:
      if "resource" in kwargs:
          # A parent node provides resource during training. The component wrapped
          # by this `GraphNode` will load itself from this resource.
          return kwargs.pop("resource")
  
      if self._existing_resource:
          # The component should be loaded from a trained resource during inference.
          # E.g. a classifier might train and persist itself during training and will
          # then load itself from this resource during inference.
          return self._existing_resource
  
      # The component gets a chance to persist itself
      return Resource(self._node_name)
  
imports: from __future__ import annotations
  import dataclasses
  from abc import ABC, abstractmethod
  from dataclasses import dataclass, field
  import logging
  from typing import Any, Callable, Dict, List, Optional, Text, Type, Tuple, Union
  from rasa.engine.exceptions import GraphComponentException, GraphRunError, GraphSchemaException
  import rasa.shared.utils.common
  import rasa.utils.common
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.exceptions import InvalidConfigException, RasaException
  from rasa.shared.data import TrainingType
label_desc: Use image node_id 3 for calling the GraphNode obj's underlying member method code with example usage: obj._get_resource(kwargs) and returns: Resource, kwargs, self