code: def sample(self, data):
      a = self.array.copy()
      masks = np.where(data == 0)[0]
      a[data != 1] = self.mask
      if self.onepass:
          s = " ".join(a)
          rs = self.probs(s)
          reps = [np.random.choice(a, p=p) for a, p in rs]
          a[masks] = reps
      else:
          for i in masks:
              s = " ".join(a)
              words, probs = self.probs(s)[0]
              a[i] = np.random.choice(words, p=probs)
      return a
  
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 SentencePerturber obj's underlying member method code with example usage: obj.sample(data) and returns: a