the random state object to be passed must be a numpy random seed
971795
def chunks(self, num_chunks=100, chunk_size=2, random_state=np.random):
    
    chunks = -np.ones_like(self.known_label_idx, dtype=int)
    uniq, lookup = np.unique(self.known_labels, return_inverse=True)
    all_inds = [set(np.where(lookup==c)[0]) for c in xrange(len(uniq))]
    idx = 0
    while idx < num_chunks and all_inds:
      if len(all_inds) == 1:
        c = 0
      else:
        c = random_state.randint(0, high=len(all_inds)-1)
      inds = all_inds[c]
      if len(inds) < chunk_size:
        del all_inds[c]
        continue
      ii = random_state.choice(list(inds), chunk_size, replace=False)
      inds.difference_update(ii)
      chunks[ii] = idx
      idx += 1
    if idx < num_chunks:
      raise ValueError('Unable to make %d chunks of %d examples each' %
                       (num_chunks, chunk_size))
    return chunks
878702
def sample(self, rstate=None):
        

        if rstate is None:
            rstate = np.random

        return rstate.rand(self.n)
16578
def _set_seed(self):
        
        if self.flags['SEED'] is not None:
            tf.set_random_seed(self.flags['SEED'])
            np.random.seed(self.flags['SEED'])
437868
def random_integers(cls, size, seed=None):
        
        if seed is None:
            seed = abs(hash("%0.20f" % time.time())) % (2 ** 31)
        return cls.from_sequence(size).hash(seed)
939842
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random:
    
    return tcod.random.Random(algo)
1152261
def random_uniform(attrs, inputs, proto_obj):
    """"""
    try:
        from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
    except ImportError:
        raise ImportError("Onnx and protobuf need to be installed. "
                          "Instructions to install - https://github.com/onnx/onnx")
    new_attrs = translation_utils._remove_attributes(attrs, ['seed'])
    new_attrs['dtype'] = TENSOR_TYPE_TO_NP_TYPE[int(new_attrs.get('dtype', 1))]
    return 'random_uniform', new_attrs, inputs
589221
def make_random(cls):
        """"""
        self = object.__new__(cls)
        self.rank = Rank.make_random()
        self.suit = Suit.make_random()
        return self
1245704
def seed(self, x=None, *args):
        
        if x is None:
            # Use same random seed code copied from Python's random.Random
            try:
                x = long(_hexlify(_urandom(16)), 16)
            except NotImplementedError:
                import time
                x = long(time.time() * 256) # use fractional seconds
        elif not isinstance(x, _Integral):
            # Use the hash of the input seed object. Note this does not give
            # consistent results cross-platform--between Python versions or
            # between 32-bit and 64-bit systems.
            x = hash(x)
        self.rng_iterator.seed(x, *args, mix_extras=True)
1190744
def init_rng(self):
        
        rng = torch.Generator()
        seed = self.seeds[self.epoch]
        logging.info(f'Sampler for epoch {self.epoch} uses seed {seed}')
        rng.manual_seed(seed)
        return rng
230737
def _random_cycle(adj, random_state):
    """"""

    # step through idx values in adj to pick a random one, random.choice does not work on dicts
    n = random_state.randint(len(adj))
    for idx, v in enumerate(adj):
        if idx == n:
            break
    start = v

    walk = [start]
    visited = {start: 0}

    while True:
        if len(walk) > 1:
            # as long as we don't step back one we won't have any repeated edges
            previous = walk[-2]
            neighbors = [u for u in adj[walk[-1]] if u != previous]
        else:
            neighbors = list(adj[walk[-1]])

        if not neighbors:
            # we've walked into a dead end
            return None

        # get a random neighbor
        u = random_state.choice(neighbors)
        if u in visited:
            # if we've seen this neighbour, then we have a cycle starting from it
            return walk[visited[u]:]
        else:
            # add to walk and keep moving
            walk.append(u)
            visited[u] = len(visited)
1273853
def get_rng(obj=None):
    
    seed = (id(obj) + os.getpid() +
            int(datetime.now().strftime("%Y%m%d%H%M%S%f"))) % 4294967295
    if _RNG_SEED is not None:
        seed = _RNG_SEED
    return np.random.RandomState(seed)
37028
def numpy_random_seed(seed=42):
    
    old_state = np.random.get_state()
    np.random.seed(seed)
    try:
        yield
    finally:
        np.random.set_state(old_state)
1263752
def RandomUniform(shape, dtype, seed):
    
    if seed:
        np.random.seed(seed)
    return np.random.uniform(size=shape).astype(dtype_map[dtype]),
1164572
def _seed(self, seed=-1):
        
        if seed != -1:
          self._random = np.random.RandomState(seed)
        else:
          self._random = np.random.RandomState()
178884
def random(self, max_number=None):
        
        min_number = self.obj
        if max_number is None:
            min_number = 0
            max_number = self.obj
        return random.randrange(min_number, max_number)
17814
def _get_seed_input(self, seed_input):
        
        desired_shape = (1, ) + K.int_shape(self.input_tensor)[1:]
        if seed_input is None:
            return utils.random_array(desired_shape, mean=np.mean(self.input_range),
                                      std=0.05 * (self.input_range[1] - self.input_range[0]))

        # Add batch dim if needed.
        if len(seed_input.shape) != len(desired_shape):
            seed_input = np.expand_dims(seed_input, 0)

        # Only possible if channel idx is out of place.
        if seed_input.shape[-1] != desired_shape[-1] and \
           seed_input.shape[1] != desired_shape[1]:
            seed_input = np.moveaxis(seed_input, -1, 1)
        return seed_input.astype(K.floatx())
684145
def rand(self, unique_pstates, random_state=None):
        
        self._init_pstates(unique_pstates)
        self._init_random(random_state=random_state)
        self._compute_marginals()
        return self