code: def insert_chars(
      aug_toks: list[types.AugTok],
      *,
      num: int | float = 1,
      lang: Optional[str] = None,
  ) -> list[types.AugTok]:
      """
      Randomly insert a character into randomly-selected words,
      up to ``num`` times or with a probability of ``num``.
  
      Args:
          aug_toks: Sequence of tokens to augment through character insertion.
          num: If int, maximum number of words to modify with a random character insertion;
              if float, probability that a given word will be modified.
          lang: Standard, two-letter language code corresponding to ``aug_toks``.
              Used to load a weighted distribution of language-appropriate characters
              that are randomly selected for substitution. More common characters
              are more likely to be substituted. If not specified, ascii letters and
              digits are randomly selected with equal probability.
  
      Returns:
          New, augmented sequence of tokens.
  
      Note:
          This transform requires :class:`textacy.datasets.UDHR` to be downloaded
          to work properly, since this is the data source for character weights when
          deciding which char(s) to insert.
      """
      _validate_aug_toks(aug_toks)
      char_weights = aug_utils.get_char_weights(lang or "xx")
      cand_idxs = [
          idx
          for idx, aug_tok in enumerate(aug_toks)
          if aug_tok.is_word and len(aug_tok.text) >= 3
      ]
      rand_idxs = set(_select_random_candidates(cand_idxs, num))
      if not rand_idxs:
          return aug_toks[:]
  
      rand_chars = iter(
          random.choices(
              [char for char, _ in char_weights],
              weights=[weight for _, weight in char_weights],
              k=len(rand_idxs),
          )
      )
      new_aug_toks = []
      for idx, aug_tok in enumerate(aug_toks):
          if idx in rand_idxs:
              text_list = list(aug_tok.text)
              rand_char_idx = random.choice(range(len(text_list)))
              text_list.insert(rand_char_idx, next(rand_chars))
              new_aug_toks.append(
                  types.AugTok(
                      text="".join(text_list),
                      ws=aug_tok.ws,
                      pos=aug_tok.pos,
                      is_word=aug_tok.is_word,
                      syns=aug_tok.syns,
                  )
              )
          else:
              new_aug_toks.append(aug_tok)
      return new_aug_toks
  
file_path: textacy/src/textacy/augmentation/transforms.py
imports: from __future__ import annotations
  import random
  from typing import Optional
  from cytoolz import itertoolz
  from ..None import errors, types, utils
  from .None import utils
label_desc: Use image node_id 6 for calling a global function with example usage: insert_chars(aug_toks) and returns: new_aug_toks, aug_toks