code: def write_text(
      data: str | Iterable[str],
      filepath: types.PathLike,
      *,
      mode: str = "wt",
      encoding: Optional[str] = None,
      make_dirs: bool = False,
      lines: bool = False,
  ) -> None:
      """
      Write text ``data`` to disk at ``filepath``, either all at once
      or streaming line-by-line.
  
      Args:
          data If ``lines`` is False, a single string to write to disk; for example::
  
                  "isnt rick and morty that thing you get when you die and your body gets all stiff"
  
              If ``lines`` is True, an iterable of strings to write to disk, one
              item per line; for example::
  
                  ["isnt rick and morty that thing you get when you die and your body gets all stiff",
                   "You're thinking of rigor mortis. Rick and morty is when you get trolled into watching \"never gonna give you up\"",
                   "That's rickrolling. Rick and morty is a type of pasta"]
  
          filepath: Path to file on disk to which data will be written.
          mode: Mode with which ``filepath`` is opened.
          encoding: Name of the encoding used to decode or encode the data in ``filepath``.
              Only applicable in text mode.
          make_dirs: If True, automatically create (sub)directories
              if not already present in order to write ``filepath``.
          lines: If False, all data is written at once;
              otherwise, data is written to disk one line at a time.
      """
      io_utils._validate_write_mode(mode)
      with io_utils.open_sesame(
          filepath, mode=mode, encoding=encoding, make_dirs=make_dirs
      ) as f:
          if lines is False:
              f.write(data)
          else:
              newline: Union[str, bytes] = (
                  "\n" if "t" in mode else b"\n"
              )
              for line in data:
                  f.write(line + newline)
  
imports: from __future__ import annotations
  from typing import Iterable, Optional, Union
  from ..None import types
  from .None import utils
label_desc: Use image node_id 2 for calling a global function with example usage: write_text(data, filepath) without return types