class_docstr: bla
class_docstr_tok: ["bla"]
code: def get_sample_fn(
      self, text, classifier_fn, onepass=False, use_proba=False
  ):
      true_label = classifier_fn([text])[0]
      processed = self.nlp(text)
      words = np.array([x.text for x in processed], dtype="|U80")
      positions = [x.idx for x in processed]
      # positions = list(range(len(words)))
      perturber = None
      if not self.use_unk_distribution:
          perturber = SentencePerturber(words, self.tg, onepass=onepass)
  
      def sample_fn(present, num_samples, compute_labels=True):
          if self.use_unk_distribution:
              data = np.ones((num_samples, len(words)))
              raw = np.zeros((num_samples, len(words)), "|U80")
              raw[:] = words
              for i, t in enumerate(words):
                  if i in present:
                      continue
                  n_changed = np.random.binomial(num_samples, 0.5)
                  changed = np.random.choice(
                      num_samples, n_changed, replace=False
                  )
                  raw[changed, i] = self.mask_string
                  data[changed, i] = 0
              raw_data = [" ".join(x) for x in raw]
          else:
              data = np.zeros((num_samples, len(words)))
              for i in range(len(words)):
                  if i in present:
                      continue
                  probs = [1 - perturber.pr[i], perturber.pr[i]]
                  data[:, i] = np.random.choice(
                      [0, 1], num_samples, p=probs
                  )
              data[:, present] = 1
              raw_data = []
              for i, d in enumerate(data):
                  r = perturber.sample(d)
                  data[i] = r == words
                  raw_data.append(" ".join(r))
          labels = []
          if compute_labels:
              labels = (classifier_fn(raw_data) == true_label).astype(
                  int
              )
          labels = np.array(labels)
          max_len = max([len(x) for x in raw_data])
          dtype = "|U%d" % (max(80, max_len))
          raw_data = np.array(raw_data, dtype).reshape(-1, 1)
          return raw_data, data, labels
  
      return words, positions, true_label, sample_fn
  
imports: from .None import utils
  from .None import anchor_base
  from .None import anchor_explanation
  import numpy
  import json
  import os
  import string
  import sys
  from io import open
  import numpy
label_desc: Use image node_id 2 for calling the AnchorText obj's underlying member method code with example usage: obj.get_sample_fn(text, classifier_fn, onepass, use_proba) and returns: words,  positions,  true_label,  sample_fn, raw_data,  data,  labels