code: def format_and_save_data(
      data: list[tuple[str, str]],
      name: str,
      save_dir: Optional[pathlib.Path] = None,
  ):
      lines = (f"__label__{lang} {text}" for text, lang in data)
      if save_dir:
          file_path = save_dir / f"{name}.txt"
          tio.text.write_text(
              lines, file_path, lines=True, make_dirs=True
          )
          print(f"saved {name} data to disk at {file_path}")
  
imports: import argparse
  import collections
  import logging
  import operator
  import pathlib
  import random
  import statistics
  from functools import partial
  from typing import Optional
  import sklearn.model_selection
  from toolz import itertoolz
  import textacy.datasets
  import textacy.io
  import textacy.lang_id._datasets
  import textacy.preprocessing
label_desc: Use image node_id 2 for calling a global function with example usage: format_and_save_data(data, name, save_dir) without return types