class_docstr: Functions related to (negative) Hamming Distance Sampling.
docstr: Sample number of tokens to corrupt from `tokens`.
docstr_tok: ["Sample","number","of","tokens","to","corrupt","from","`","tokens","`","."]
code: def _sample_distance(self, tokens, temperature):
      """Sample number of tokens to corrupt from `tokens`."""
      n_tokens = len(tokens)
      indices = np.arange(n_tokens)
      logits = indices * -1 * temperature
      probs = self._softmax(logits)
      distance = np.random.choice(indices, p=probs)
      return distance
  
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 3 for calling the HammingDistanceSampling obj's underlying member method code with example usage: obj._sample_distance(tokens, temperature) and returns: distance