code: def _create_from_endpoint_config(
      endpoint_config: Optional[EndpointConfig] = None,
      domain: Optional[Domain] = None,
  ) -> "NaturalLanguageGenerator":
      """Given an endpoint configuration, create a proper NLG object."""
      domain = domain or Domain.empty()
  
      if endpoint_config is None:
          from rasa.core.nlg import TemplatedNaturalLanguageGenerator
  
          # this is the default type if no endpoint config is set
          nlg: "NaturalLanguageGenerator" = (
              TemplatedNaturalLanguageGenerator(domain.responses)
          )
      elif (
          endpoint_config.type is None
          or endpoint_config.type.lower() == "callback"
      ):
          from rasa.core.nlg import CallbackNaturalLanguageGenerator
  
          # this is the default type if no nlg type is set
          nlg = CallbackNaturalLanguageGenerator(
              endpoint_config=endpoint_config
          )
      elif endpoint_config.type.lower() == "response":
          from rasa.core.nlg import TemplatedNaturalLanguageGenerator
  
          nlg = TemplatedNaturalLanguageGenerator(domain.responses)
      else:
          nlg = _load_from_module_name_in_endpoint_config(
              endpoint_config, domain
          )
  
      logger.debug(f"Instantiated NLG to '{nlg.__class__.__name__}'.")
      return nlg
  
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 1 for calling a global function with example usage: _create_from_endpoint_config(endpoint_config, domain) and returns: nlg