#NEWLINE# def shaped_random( shape , xp = cupy , dtype = numpy . float32 , scale = 10 , seed = 0 ) : #NEWLINE# #INDENT# 'Returns an array filled with random values.\n\n    Args:\n         shape(tuple): Shape of returned ndarray.\n         xp(numpy or cupy): Array module to use.\n         dtype(dtype): Dtype of returned ndarray.\n         scale(float): Scaling factor of elements.\n         seed(int): Random seed.\n\n    Returns:\n         numpy.ndarray or cupy.ndarray: The array with\n             given shape, array module,\n\n    If ``dtype`` is ``numpy.bool_``, the elements are\n    independetly drawn from ``True`` and ``False``\n    with same probabilities.\n    Otherwise, the array is filled with samples\n    independently and identically drawn\n    from uniform distribution over :math:`[0, scale)`\n    with specified dtype.\n    ' #NEWLINE# numpy . random . seed ( seed ) #NEWLINE# if ( numpy . dtype ( dtype ) . type == numpy . bool_ ) : #NEWLINE# #INDENT# return xp . asarray ( numpy . random . randint ( 2 , size = shape ) . astype ( dtype ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return xp . asarray ( ( numpy . random . rand ( * shape ) * scale ) . astype ( dtype ) )