docstr: The function returns a `numpy` array of `num_samples` where randomly chosen features,
  except those in anchor, are replaced by ``'UNK'`` token.
  
  Parameters
  ----------
  anchor:
      Indices represent the positions of the words to be kept unchanged.
  num_samples:
      Number of perturbed sentences to be returned.
  
  Returns
  -------
  raw
      Array containing num_samples elements. Each element is a perturbed sentence.
  data
      A `(num_samples, m)`-dimensional boolean array, where `m` is the number of tokens
      in the instance to be explained.
docstr_tok: ["The","function","returns","a","`","numpy","`","array","of","`","num_samples","`","where","randomly","chosen","features",",","except","those","in","anchor",",","are","replaced","by","``","'UNK","'","``","token",".","Parameters","--","--","--","--","--","anchor",":","Indices","represent","the","positions","of","the","words","to","be","kept","unchanged",".","num_samples",":","Number","of","perturbed","sentences","to","be","returned",".","Returns","--","--","--","-","raw","Array","containing","num_samples","elements",".","Each","element","is","a","perturbed","sentence",".","data","A","`","(","num_samples",",","m",")","`","-dimensional","boolean","array",",","where","`","m","`","is","the","number","of","tokens","in","the","instance","to","be","explained","."]
code: def __call__(
      self, anchor: tuple, num_samples: int
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      The function returns a `numpy` array of `num_samples` where randomly chosen features,
      except those in anchor, are replaced by ``'UNK'`` token.
  
      Parameters
      ----------
      anchor:
          Indices represent the positions of the words to be kept unchanged.
      num_samples:
          Number of perturbed sentences to be returned.
  
      Returns
      -------
      raw
          Array containing num_samples elements. Each element is a perturbed sentence.
      data
          A `(num_samples, m)`-dimensional boolean array, where `m` is the number of tokens
          in the instance to be explained.
      """
      assert self.perturb_opts, "Perturbation options are not set."
  
      # allocate memory for the binary mask and the perturbed instances
      data = np.ones((num_samples, len(self.words)))
      raw = np.zeros((num_samples, len(self.words)), self.dtype)
  
      # fill each row of the raw data matrix with the text instance to be explained
      raw[:] = self.words
  
      for i, t in enumerate(self.words):
          # do not perturb words that are in anchor
          if i in anchor:
              continue
  
          # sample the words in the text outside of the anchor that are replaced with UNKs
          n_changed = np.random.binomial(
              num_samples, self.perturb_opts["sample_proba"]
          )
          changed = np.random.choice(
              num_samples, n_changed, replace=False
          )
          raw[changed, i] = UnknownSampler.UNK
          data[changed, i] = 0
  
      # join the words
      raw = np.apply_along_axis(
          self._joiner, axis=1, arr=raw, dtype=self.dtype
      )
      return raw, data
  
imports: import logging
  from abc import abstractmethod
  from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
  import numpy
  import spacy
label_desc: Use image node_id 3 for calling the UnknownSampler obj's underlying member method code with example usage: obj.__call__(anchor, num_samples) and returns: raw,  data