def permutation_helper(random_state, n, shape):
 assert (n.shape == ())
 n = int(n.item())
 if (shape is None):
  shape = ()
 out_shape = list(shape)
 out_shape.append(n)
 out = numpy.empty(out_shape, int)
 for i in numpy.ndindex(*shape):
  out[i] = random_state.permutation(n)
 return out

def permutation_helper ( random_state , n , shape ) : assert ( n . shape == ( ) ) n = int ( n . item ( ) ) if ( shape is None ) : shape = ( ) out_shape = list ( shape ) out_shape . append ( n ) out = numpy . empty ( out_shape , int ) for i in numpy . ndindex ( * shape ) : out [ i ] = random_state . permutation ( n ) return out
helper function to generate permutations from integers .