code: def train_word_vectors(
      input: WordVectorTrainingInput,
  ) -> WordVectorTrainingOutput:
      """Trains word vectors via [FastText](https://fasttext.cc) based on a provided text."""
  
      with NamedTemporaryFile(
          suffix=".txt", mode="w", encoding="utf-8"
      ) as f:
          f.write(input.text)
          f.seek(0)
  
          model = fasttext.train_unsupervised(
              f.name,
              model=input.model.value,
              lr=input.learning_rate,
              dim=input.dimension,
              epoch=input.epoch,
              minCount=input.min_count,
              loss=input.loss_function,
              thread=1,  # only train with one thread to not block other demos
          )
  
          with NamedTemporaryFile(
              suffix=".vec", mode="w+b"
          ) as vec_file:
              words = model.get_words()
              for word in words:
                  vec_file.write(
                      str.encode(
                          word
                          + "".join(
                              " " + str(vi)
                              for vi in model.get_word_vector(word)
                          )
                          + "\n"
                      )
                  )
              vec_file.seek(0)
              return WordVectorTrainingOutput(
                  vector_file=vec_file.read()
              )
  
file_path: opyrator/examples/train_word_vectors/app.py
imports: from enum import Enum
  from tempfile import NamedTemporaryFile
  import fasttext
  from pydantic import BaseModel, Field
  from opyrator.components.types import FileContent
label_desc: Use image node_id 1 for calling a global function with example usage: train_word_vectors(input) and returns: WordVectorTrainingOutput