class_docstr: A class for writing training data to a file.
docstr: Generates text for one or multiple entity objects.
  
  Args:
      text: The un-annotated text
      entity: One or multiple entity annotations for one part of this text
  
  Returns:
      Annotated part of the text
docstr_tok: ["Generates","text","for","one","or","multiple","entity","objects",".","Args",":","text",":","The","un-annotated","text","entity",":","One","or","multiple","entity","annotations","for","one","part","of","this","text","Returns",":","Annotated","part","of","the","text"]
code: def generate_entity(
      text: Text, entity: Union[Dict[Text, Any], List[Dict[Text, Any]]]
  ) -> Text:
      """Generates text for one or multiple entity objects.
  
      Args:
          text: The un-annotated text
          entity: One or multiple entity annotations for one part of this text
  
      Returns:
          Annotated part of the text
      """
      if isinstance(entity, list):
          entity_text = text[
              entity[0][ENTITY_ATTRIBUTE_START] : entity[0][
                  ENTITY_ATTRIBUTE_END
              ]
          ]
          return (
              f"[{entity_text}]["
              + ", ".join(
                  [
                      TrainingDataWriter.generate_entity_attributes(
                          text=entity_text,
                          entity=e,
                          short_allowed=False,
                      )
                      for e in entity
                  ]
              )
              + "]"
          )
      else:
          entity_text = text[
              entity[ENTITY_ATTRIBUTE_START] : entity[
                  ENTITY_ATTRIBUTE_END
              ]
          ]
          return (
              f"[{entity_text}]"
              + TrainingDataWriter.generate_entity_attributes(
                  text=entity_text, entity=entity, short_allowed=True
              )
          )
  
imports: import abc
  import json
  from collections import OrderedDict
  from pathlib import Path
  import rasa.shared.nlu.training_data.util
  from rasa.shared.constants import INTENT_MESSAGE_PREFIX
  from rasa.shared.nlu.constants import INTENT, ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE
  import rasa.shared.utils.io
  import typing
  from typing import Text, Dict, Any, Union, List
  from collections import defaultdict
label_desc: Use image node_id 7 for calling the TrainingDataWriter obj's underlying member method code with example usage: obj.generate_entity(text, entity) and returns: unknown, unknown