code: def _get_permutations(num_results, dims, seed=None):
      """Uniform iid sample from the space of permutations.
  
      Draws a sample of size `num_results` from the group of permutations of degrees
      specified by the `dims` tensor. These are packed together into one tensor
      such that each row is one sample from each of the dimensions in `dims`. For
      example, if dims = [2,3] and num_results = 2, the result is a tensor of shape
      [2, 2 + 3] and the first row of the result might look like:
      [1, 0, 2, 0, 1]. The first two elements are a permutation over 2 elements
      while the next three are a permutation over 3 elements.
  
      Args:
        num_results: A positive scalar `Tensor` of integral type. The number of
          draws from the discrete uniform distribution over the permutation groups.
        dims: A 1D numpy array of the same dtype as `num_results`. The degree of the
          permutation groups from which to sample.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
  
      Returns:
        permutations: A `Tensor` of shape `[num_results, sum(dims)]` and the same
        dtype as `dims`.
      """
      n = dims.size
      max_size = np.max(dims)
      samples = samplers.uniform([num_results, n, max_size], seed=seed)
      should_mask = np.arange(max_size) >= dims[..., np.newaxis]
      # Choose a number that does not affect the permutation and relative location.
      samples = tf.where(
          should_mask,
          dtype_util.as_numpy_dtype(samples.dtype)(
              np.arange(max_size) + 10.0
          ),
          samples,
      )
      samples = tf.argsort(samples, axis=-1)
      # Generate the set of indices to gather.
      should_mask = np.tile(should_mask, [num_results, 1, 1])
      indices = np.stack(np.where(~should_mask), axis=-1)
      return tf.gather_nd(samples, indices)
  
file_path: probability/tensorflow_probability/python/mcmc/sample_halton_sequence_lib.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
label_desc: Use image node_id 3 for calling a global function with example usage: _get_permutations(num_results, dims, seed) and returns: tf