code: def split_stories_data(args: argparse.Namespace) -> None:
      """Load data from a file path and split stories into test and train examples.
  
      Args:
          args: Commandline arguments
      """
      from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
          YAMLStoryReader,
          KEY_STORIES,
      )
      from sklearn.model_selection import train_test_split
  
      data_path = rasa.cli.utils.get_validated_path(
          args.nlu, "nlu", DEFAULT_DATA_PATH
      )
      data_files = rasa.shared.data.get_data_files(
          data_path, YAMLStoryReader.is_stories_file
      )
      out_path = pathlib.Path(args.out)
      out_path.mkdir(parents=True, exist_ok=True)
  
      # load Yaml stories data
      for file_name in data_files:
          file_data = rasa.shared.utils.io.read_yaml_file(file_name)
          assert isinstance(file_data, dict)
          stories = file_data.get(KEY_STORIES, [])
          if not stories:
              logger.info(f"File {file_name} has no stories, skipped")
              continue
  
          file_path = pathlib.Path(file_name)
  
          # everything besides stories are going into the training data
          train, test = train_test_split(
              stories,
              test_size=1 - args.training_fraction,
              random_state=args.random_seed,
          )
          out_file_train = out_path / ("train_" + file_path.name)
          out_file_test = out_path / ("test_" + file_path.name)
  
          # train file contains everything else from the file + train stories
          file_data[KEY_STORIES] = train
          rasa.shared.utils.io.write_yaml(file_data, out_file_train)
  
          # test file contains just test stories
          rasa.shared.utils.io.write_yaml(
              {KEY_STORIES: test}, out_file_test
          )
          logger.info(
              f"From {file_name} we produced {out_file_train} "
              f"with {len(train)} stories and {out_file_test} "
              f"with {len(test)} stories"
          )
  
imports: import argparse
  import logging
  import pathlib
  from typing import List
  import rasa.shared.core.domain
  from rasa import telemetry
  from rasa.cli import SubParsersAction
  from rasa.cli.arguments import data
  from rasa.cli.arguments import default_arguments
  import rasa.cli.utils
  from rasa.shared.constants import DEFAULT_DATA_PATH, DEFAULT_CONFIG_PATH, DEFAULT_DOMAIN_PATH
  import rasa.shared.data
  from rasa.shared.importers.importer import TrainingDataImporter
  import rasa.shared.nlu.training_data.loading
  import rasa.shared.nlu.training_data.util
  import rasa.shared.utils.cli
  import rasa.utils.common
  import rasa.shared.utils.io
label_desc: Use image node_id 8 for calling a global function with example usage: split_stories_data(args) without return types