code: def generate_samples(
      text,  # type: TokenizedText
      n_samples=500,  # type: int
      bow=True,  # type: bool
      random_state=None,
      replacement="",  # type: str
      min_replace=1,  # type: Union[int, float]
      max_replace=1.0,  # type: Union[int, float]
      group_size=1,  # type: int
  ):
      # type: (...) -> Tuple[List[str], np.ndarray, np.ndarray]
      """
      Return ``n_samples`` changed versions of text (with some words removed),
      along with distances between the original text and a generated
      examples. If ``bow=False``, all tokens are considered unique
      (i.e. token position matters).
      """
      kwargs = dict(
          n_samples=n_samples,
          replacement=replacement,
          random_state=random_state,
          min_replace=min_replace,
          max_replace=max_replace,
      )
      if bow:
          num_tokens = len(text.vocab)
          res = text.replace_random_tokens_bow(**kwargs)
      else:
          num_tokens = len(text.tokens)
          res = text.replace_random_tokens(
              group_size=group_size, **kwargs
          )
  
      texts, num_removed_vec, masks = zip(*res)
      similarity = cosine_similarity_vec(num_tokens, num_removed_vec)
      return texts, similarity, vstack(masks)
  
imports: from __future__ import absolute_import
  import re
  import math
  from typing import List, Tuple, Union, Optional
  import numpy
  from sklearn.utils import check_random_state
  from eli5.utils import indices_to_bool_mask, vstack
label_desc: Use image node_id 1 for calling a global function with example usage: generate_samples(text, n_samples, bow, random_state, replacement, min_replace, max_replace, group_size) and returns: texts,  similarity,  vstack