code: def _reader_factory(fformat: Text) -> Optional["TrainingDataReader"]:
      """Generates the appropriate reader class based on the file format."""
      from rasa.shared.nlu.training_data.formats import (
          RasaYAMLReader,
          WitReader,
          LuisReader,
          RasaReader,
          DialogflowReader,
      )
  
      reader: Optional["TrainingDataReader"] = None
      if fformat == LUIS:
          reader = LuisReader()
      elif fformat == WIT:
          reader = WitReader()
      elif fformat in DIALOGFLOW_RELEVANT:
          reader = DialogflowReader()
      elif fformat == RASA:
          reader = RasaReader()
      elif fformat == RASA_YAML:
          reader = RasaYAMLReader()
      return reader
  
file_path: rasa/rasa/shared/nlu/training_data/loading.py
imports: import json
  import logging
  import os
  import typing
  from typing import Optional, Text, Callable, Dict, Any, List
  import rasa.shared.utils.io
  from rasa.shared.nlu.training_data.formats.dialogflow import DIALOGFLOW_AGENT, DIALOGFLOW_ENTITIES, DIALOGFLOW_ENTITY_ENTRIES, DIALOGFLOW_INTENT, DIALOGFLOW_INTENT_EXAMPLES, DIALOGFLOW_PACKAGE
  from rasa.shared.nlu.training_data.training_data import TrainingData
label_desc: Use image node_id 2 for calling a global function with example usage: _reader_factory(fformat) and returns: reader