class_docstr: Fairly samples a slice from a set of variable sized chunks.
  
  'Fairly' means that the distribution is the same as sampling from one concatenated chunk,
  but without crossing chunk boundaries.
class_docstr_tok: ["Fairly","samples","a","slice","from","a","set","of","variable","sized","chunks",".","'Fairly","'","means","that","the","distribution","is","the","same","as","sampling","from","one","concatenated","chunk",",","but","without","crossing","chunk","boundaries","."]
code: def sample(self, length):
      assert length < self.total_size // len(
          self.chunks
      ), "Dataset files are too small to sample {} tokens at a time".format(
          length
      )
      while True:
          index = random.randint(0, self.total_size - length - 1)
          i = (
              binary_search(
                  lambda j: self.boundaries[j] > index,
                  0,
                  len(self.boundaries) - 1,
              )
              - 1
          )
          if self.boundaries[i + 1] > index + length:
              within_chunk = index - self.boundaries[i]
              return self.chunks[i][
                  within_chunk : within_chunk + length
              ]
  
file_path: gpt-2-simple/gpt_2_simple/src/load_dataset.py
imports: import glob
  import numpy
  import os
  import random
  import tensorflow
  import tqdm
  import csv
label_desc: Use image node_id 2 for calling the Sampler obj's underlying member method code with example usage: obj.sample(length) and returns: self