class_docstr: Writes Core training data into a file in a YAML format.
docstr: Converts a single user utterance into an ordered dict.
  
  Args:
      user_utterance: Original user utterance object.
      is_test_story: Identifies if the user utterance should be added
                     to the final YAML or not.
  
  Returns:
      Dict with a user utterance.
docstr_tok: ["Converts","a","single","user","utterance","into","an","ordered","dict",".","Args",":","user_utterance",":","Original","user","utterance","object",".","is_test_story",":","Identifies","if","the","user","utterance","should","be","added","to","the","final","YAML","or","not",".","Returns",":","Dict","with","a","user","utterance","."]
code: def process_user_utterance(
      user_utterance: UserUttered, is_test_story: bool = False
  ) -> OrderedDict:
      """Converts a single user utterance into an ordered dict.
  
      Args:
          user_utterance: Original user utterance object.
          is_test_story: Identifies if the user utterance should be added
                         to the final YAML or not.
  
      Returns:
          Dict with a user utterance.
      """
      result = CommentedMap()
      if (
          user_utterance.intent_name
          and not user_utterance.use_text_for_featurization
      ):
          result[KEY_USER_INTENT] = (
              user_utterance.full_retrieval_intent_name
              if user_utterance.full_retrieval_intent_name
              else user_utterance.intent_name
          )
  
      entities = []
      if len(user_utterance.entities) and not is_test_story:
          for entity in user_utterance.entities:
              if "value" in entity:
                  if hasattr(
                      user_utterance, "inline_comment_for_entity"
                  ):
                      # FIXME: to fix this type issue, WronglyClassifiedUserUtterance
                      # needs to be imported but it's currently outside
                      # of `rasa.shared`
                      for predicted in user_utterance.predicted_entities:  # type: ignore[attr-defined] # noqa: E501
                          if predicted["start"] == entity["start"]:
                              commented_entity = user_utterance.inline_comment_for_entity(  # noqa: E501
                                  predicted, entity
                              )
                              if commented_entity:
                                  entity_map = CommentedMap(
                                      [
                                          (
                                              entity["entity"],
                                              entity["value"],
                                          )
                                      ]
                                  )
                                  entity_map.yaml_add_eol_comment(
                                      commented_entity, entity["entity"]
                                  )
                                  entities.append(entity_map)
                              else:
                                  entities.append(
                                      OrderedDict(
                                          [
                                              (
                                                  entity["entity"],
                                                  entity["value"],
                                              )
                                          ]
                                      )
                                  )
                  else:
                      entities.append(
                          OrderedDict(
                              [(entity["entity"], entity["value"])]
                          )
                      )
              else:
                  entities.append(entity["entity"])
          result[KEY_ENTITIES] = entities
  
      if hasattr(user_utterance, "inline_comment"):
          # FIXME: to fix this type issue, WronglyClassifiedUserUtterance needs to
          # be imported but it's currently outside of `rasa.shared`
          comment = user_utterance.inline_comment(
              force_comment_generation=not entities
          )
          if comment:
              result.yaml_add_eol_comment(comment, KEY_USER_INTENT)
  
      if user_utterance.text and (
          # We only print the utterance text if it was an end-to-end prediction
          user_utterance.use_text_for_featurization
          # or if we want to print a conversation test story.
          or is_test_story
      ):
          result[KEY_USER_MESSAGE] = LiteralScalarString(
              rasa.shared.core.events.format_message(
                  user_utterance.text,
                  user_utterance.intent_name,
                  user_utterance.entities,
              )
          )
  
      return result
  
imports: from collections import OrderedDict
  from pathlib import Path
  from typing import Any, Dict, List, Text, Union, Optional
  from ruamel import yaml
  from ruamel.yaml.comments import CommentedMap
  from ruamel.yaml.scalarstring import DoubleQuotedScalarString, LiteralScalarString
  import rasa.shared.utils.io
  import rasa.shared.core.constants
  from rasa.shared.constants import LATEST_TRAINING_DATA_FORMAT_VERSION
  import rasa.shared.core.events
  from rasa.shared.core.events import UserUttered, ActionExecuted, SlotSet, ActiveLoop, Event
  from rasa.shared.core.training_data.story_reader.yaml_story_reader import KEY_STORIES, KEY_STORY_NAME, KEY_USER_INTENT, KEY_ENTITIES, KEY_ACTION, KEY_STEPS, KEY_CHECKPOINT, KEY_SLOT_NAME, KEY_CHECKPOINT_SLOTS, KEY_OR, KEY_USER_MESSAGE, KEY_ACTIVE_LOOP, KEY_BOT_END_TO_END_MESSAGE, KEY_RULES, KEY_RULE_FOR_CONVERSATION_START, KEY_WAIT_FOR_USER_INPUT_AFTER_RULE, KEY_RULE_CONDITION, KEY_RULE_NAME
  from rasa.shared.core.training_data.story_writer.story_writer import StoryWriter
  from rasa.shared.core.training_data.structures import StoryStep, Checkpoint, STORY_START, RuleStep
label_desc: Use image node_id 7 for calling the YAMLStoryWriter obj's underlying member method code with example usage: obj.process_user_utterance(user_utterance, is_test_story) and returns: result