code: def _load_from_module_name_in_endpoint_config(
      endpoint_config: EndpointConfig, domain: Domain
  ) -> "NaturalLanguageGenerator":
      """Initializes a custom natural language generator.
  
      Args:
          domain: defines the universe in which the assistant operates
          endpoint_config: the specific natural language generator
      """
      try:
          nlg_class = rasa.shared.utils.common.class_from_module_path(
              endpoint_config.type
          )
          return nlg_class(
              endpoint_config=endpoint_config, domain=domain
          )
      except (AttributeError, ImportError) as e:
          raise Exception(
              f"Could not find a class based on the module path "
              f"'{endpoint_config.type}'. Failed to create a "
              f"`NaturalLanguageGenerator` instance. Error: {e}"
          )
  
file_path: rasa/rasa/core/nlg/generator.py
imports: import logging
  from typing import List, Optional, Union, Text, Any, Dict
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  from rasa.shared.constants import CHANNEL, RESPONSE_CONDITION
  from rasa.shared.core.domain import Domain
  from rasa.utils.endpoints import EndpointConfig
  from rasa.shared.core.trackers import DialogueStateTracker
label_desc: Use image node_id 2 for calling a global function with example usage: _load_from_module_name_in_endpoint_config(endpoint_config, domain) and returns: nlg_class