class_docstr: Functions related to (negative) Hamming Distance Sampling.
docstr: Sample a token from `vocab` other than `reject`.
docstr_tok: ["Sample","a","token","from","`","vocab","`","other","than","`","reject","`","."]
code: def _sample_replace(self, vocab, reject):
      """Sample a token from `vocab` other than `reject`."""
      token = reject
      while token == reject:
          token = random.choice(vocab)
      return token
  
imports: import random
  import numpy
  from onmt.constants import DefaultTokens
  from onmt.transforms import register_transform
  from .transform import Transform, ObservableStats
label_desc: Use image node_id 2 for calling the HammingDistanceSampling obj's underlying member method code with example usage: obj._sample_replace(vocab, reject) and returns: token