code: def test_writing_end_to_end_stories(domain: Domain):
      story_name = "test_writing_end_to_end_stories"
      events = [
          # Training story story with intent and action labels
          ActionExecuted(ACTION_LISTEN_NAME),
          UserUttered(intent={"name": "greet"}),
          ActionExecuted("utter_greet"),
          ActionExecuted(ACTION_LISTEN_NAME),
          # Prediction story story with intent and action labels
          ActionExecuted(ACTION_LISTEN_NAME),
          UserUttered(text="Hi", intent={"name": "greet"}),
          DefinePrevUserUtteredFeaturization(
              use_text_for_featurization=False
          ),
          ActionExecuted("utter_greet"),
          ActionExecuted(ACTION_LISTEN_NAME),
          # End-To-End Training Story
          UserUttered(text="Hi"),
          ActionExecuted(action_text="Hi, I'm a bot."),
          ActionExecuted(ACTION_LISTEN_NAME),
          # End-To-End Prediction Story
          UserUttered("Hi", intent={"name": "greet"}),
          DefinePrevUserUtteredFeaturization(
              use_text_for_featurization=True
          ),
          ActionExecuted(action_text="Hi, I'm a bot."),
          ActionExecuted(ACTION_LISTEN_NAME),
      ]
  
      tracker = DialogueStateTracker.from_events(story_name, events)
      dump = YAMLStoryWriter().dumps(tracker.as_story().story_steps)
  
      assert (
          dump.strip()
          == textwrap.dedent(
              f"""
          version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
          stories:
          - story: {story_name}
            steps:
            - intent: greet
            - action: utter_greet
            - intent: greet
            - action: utter_greet
            - user: |-
                Hi
            - bot: Hi, I'm a bot.
            - user: |-
                Hi
            - bot: Hi, I'm a bot.
      """
          ).strip()
      )
  
imports: from pathlib import Path
  import textwrap
  from typing import Text
  from collections import OrderedDict
  import pytest
  from rasa.shared.constants import LATEST_TRAINING_DATA_FORMAT_VERSION
  from rasa.shared.core.constants import ACTION_SESSION_START_NAME, ACTION_LISTEN_NAME, ACTION_UNLIKELY_INTENT_NAME
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.events import ActionExecuted, UserUttered, DefinePrevUserUtteredFeaturization
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.training_data.story_reader.yaml_story_reader import YAMLStoryReader
  from rasa.shared.core.training_data.story_writer.yaml_story_writer import YAMLStoryWriter
  from rasa.shared.core.training_data.structures import STORY_START
label_desc: Use image node_id 7 for calling a global function with example usage: test_writing_end_to_end_stories(domain) without return types