class_docstr: Translation with muli-lingual vocabulary, small (6K) training data.
docstr: Generate just the first 6k samples for training.
docstr_tok: ["Generate","just","the","first","6k","samples","for","training","."]
code: def generate_samples(self, data_dir, tmp_dir, dataset_split):
      """Generate just the first 6k samples for training."""
      # If not training, do the same as before.
      if dataset_split != problem.DatasetSplit.TRAIN:
          for x in super(
              TranslateEnroWmtMultiSmall64k, self
          ).generate_samples(data_dir, tmp_dir, dataset_split):
              yield x
          raise StopIteration
      # Now we assume we're training.
      counter = 0
      # The size of this data-set in total is around 614K, we want to sample so
      # that in expectation we take the requested number of samples in 1 go.
      sample_prob = self.how_many_examples_to_sample / float(614000)
      # Let's sample.
      for x in super(
          TranslateEnroWmtMultiSmall64k, self
      ).generate_samples(data_dir, tmp_dir, dataset_split):
          if random.random() > sample_prob:
              continue
          counter += 1
          if counter > self.how_many_examples_to_sample:
              raise StopIteration
          yield x
      # We do it again if we don't have enough samples.
      if counter < self.how_many_examples_to_sample:
          for x in super(
              TranslateEnroWmtMultiSmall64k, self
          ).generate_samples(data_dir, tmp_dir, dataset_split):
              if random.random() > sample_prob:
                  continue
              counter += 1
              if counter > self.how_many_examples_to_sample:
                  raise StopIteration
              yield x
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import random
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_problems
  from tensor2tensor.data_generators import translate
  from tensor2tensor.data_generators import wiki_lm
  from tensor2tensor.utils import registry
label_desc: Use image node_id 4 for calling the TranslateEnroWmtMultiSmall64k obj's underlying member method code with example usage: obj.generate_samples(data_dir, tmp_dir, dataset_split) without return types