code: def rng_integers(
      gen, low, high=None, size=None, dtype="int64", endpoint=False
  ):
      """
      Return random integers from low (inclusive) to high (exclusive), or if
      endpoint=True, low (inclusive) to high (inclusive). Replaces
      `RandomState.randint` (with endpoint=False) and
      `RandomState.random_integers` (with endpoint=True).
  
      Return random integers from the "discrete uniform" distribution of the
      specified dtype. If high is None (the default), then results are from
      0 to low.
  
      Parameters
      ----------
      gen : {None, np.random.RandomState, np.random.Generator}
          Random number generator. If None, then the np.random.RandomState
          singleton is used.
      low : int or array-like of ints
          Lowest (signed) integers to be drawn from the distribution (unless
          high=None, in which case this parameter is 0 and this value is used
          for high).
      high : int or array-like of ints
          If provided, one above the largest (signed) integer to be drawn from
          the distribution (see above for behavior if high=None). If array-like,
          must contain integer values.
      size : array-like of ints, optional
          Output shape. If the given shape is, e.g., (m, n, k), then m * n * k
          samples are drawn. Default is None, in which case a single value is
          returned.
      dtype : {str, dtype}, optional
          Desired dtype of the result. All dtypes are determined by their name,
          i.e., 'int64', 'int', etc, so byteorder is not available and a specific
          precision may have different C types depending on the platform.
          The default value is np.int_.
      endpoint : bool, optional
          If True, sample from the interval [low, high] instead of the default
          [low, high) Defaults to False.
  
      Returns
      -------
      out: int or ndarray of ints
          size-shaped array of random integers from the appropriate distribution,
          or a single such random int if size not provided.
      """
      if isinstance(gen, Generator):
          return gen.integers(
              low, high=high, size=size, dtype=dtype, endpoint=endpoint
          )
      else:
          if gen is None:
              # default is RandomState singleton used by np.random.
              gen = np.random.mtrand._rand
          if endpoint:
              # inclusive of endpoint
              # remember that low and high can be arrays, so don't modify in
              # place
              if high is None:
                  return gen.randint(low + 1, size=size, dtype=dtype)
              if high is not None:
                  return gen.randint(
                      low, high=high + 1, size=size, dtype=dtype
                  )
  
          # exclusive
          return gen.randint(low, high=high, size=size, dtype=dtype)
  
imports: from contextlib import contextmanager
  import functools
  import operator
  import sys
  import warnings
  import numbers
  from collections import namedtuple
  import inspect
  import math
  from typing import Optional, Union, TYPE_CHECKING, TypeVar
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: rng_integers(gen, low, high, size, dtype, endpoint) and returns: gen, gen, gen, gen