class_docstr: Dumps NLU data as Rasa JSON string.
class_docstr_tok: ["Dumps","NLU","data","as","Rasa","JSON","string","."]
docstr: Writes Training Data to a string in json format.
docstr_tok: ["Writes","Training","Data","to","a","string","in","json","format","."]
code: def dumps(self, training_data: "TrainingData", **kwargs: Any) -> Text:
      """Writes Training Data to a string in json format."""
      js_entity_synonyms = defaultdict(list)
      for k, v in training_data.entity_synonyms.items():
          if k != v:
              js_entity_synonyms[v].append(k)
  
      formatted_synonyms = [
          {"value": value, "synonyms": syns}
          for value, syns in js_entity_synonyms.items()
      ]
  
      formatted_examples = [
          example.as_dict_nlu()
          for example in training_data.training_examples
      ]
  
      return json_to_string(
          {
              "rasa_nlu_data": {
                  "common_examples": formatted_examples,
                  "regex_features": training_data.regex_features,
                  "lookup_tables": training_data.lookup_tables,
                  "entity_synonyms": formatted_synonyms,
              }
          },
          **kwargs,
      )
  
file_path: rasa/rasa/shared/nlu/training_data/formats/rasa.py
imports: import logging
  from collections import defaultdict
  from typing import Any, Dict, Text
  from rasa.shared.constants import DOCS_URL_MIGRATION_GUIDE
  from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES
  from rasa.shared.nlu.training_data.formats.readerwriter import JsonTrainingDataReader, TrainingDataWriter
  from rasa.shared.nlu.training_data.util import transform_entity_synonyms
  from rasa.shared.utils.io import json_to_string
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  import rasa.shared.utils.io
label_desc: Use image node_id 2 for calling the RasaWriter obj's underlying member method code with example usage: obj.dumps(training_data) and returns: json_to_string