code: def train_sentencepiece(
      dump_text_path: Union[str, Path],
      output_path: Union[str, Path],
      vocab_size: int = 5000,
      character_coverage: float = 0.9995,
  ):
      """Main function to train sentencepiece model.
  
      Args:
          dump_text_path (Union[str, Path]): Path to the train.txt file.
          output_path (Union[str, Path]): Output directory to store
              sentencepiece model and vocaburary list.
          vocab_size (int, optional): Vocaburary size. Defaults to 5000.
          character_coverage (float, optional): Character coverage.
              Defaults to 0.9995.
      """
      # Please prepare sentences before running this function.
      spm.SentencePieceTrainer.Train(
          input=dump_text_path,
          model_prefix="bpe",
          model_type="bpe",
          vocab_size=vocab_size,
          character_coverage=character_coverage,
          user_defined_symbols=[],
      )
      if not os.path.exists(output_path):
          os.makedirs(output_path)
  
      shutil.move("bpe.model", output_path)
      shutil.move("bpe.vocab", output_path)
  
      # create vocab file
      with open(os.path.join(output_path, "bpe.vocab"), "r") as f:
          lines = f.readlines()
  
      vocabs = (
          ["<blank>", "<unk>"]
          + [line.split("\t")[0] for line in lines][3:]
          + ["<sos/eos>"]
      )
      with open(os.path.join(output_path, "tokens.txt"), "w") as f:
          f.write("\n".join(vocabs))
  
imports: import os
  import shutil
  from pathlib import Path
  from typing import Union
  import sentencepiece
label_desc: Use image node_id 2 for calling a global function with example usage: train_sentencepiece(dump_text_path, output_path, vocab_size, character_coverage) without return types