code: def weighted(weights, sample_size, with_replacement=False):
          
          assert sample_size <= len(weights), "The sample size must be smaller \
  than or equal to the number of weights it's taken from."
  
          # Convert weights to floats
          weights = [float(w) for w in weights]
          weight_indexes = list(range(0, len(weights)))
  
          samples = []
          while len(samples) < sample_size:
              # Choice a weight
              sample = OneOf.weighted(weights)
  
              # Add the choosen weight to our samples
              samples.append(weight_indexes[sample])
  
              if not with_replacement:
                  # Remove the weight from the list of weights we can select from
                  del weights[sample]
                  del weight_indexes[sample]
  
          return samples
docs: Return a set of random integers 0 <= N <= len(weights) - 1, where the
          weights determine the probability of each possible integer in the set.