#NEWLINE# def tile( A , reps ) : #NEWLINE# #INDENT# 'Construct an array by repeating A the number of times given by reps.\n\n    Args:\n        A (cupy.ndarray): Array to transform.\n        reps (int or tuple): The number of repeats.\n\n    Returns:\n        cupy.ndarray: Transformed array with repeats.\n\n    .. seealso:: :func:`numpy.tile`\n\n    ' #NEWLINE# try : #NEWLINE# #INDENT# tup = tuple ( reps ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# tup = ( reps , ) #NEWLINE# #UNINDENT# d = len ( tup ) #NEWLINE# if ( ( tup . count ( 1 ) == len ( tup ) ) and isinstance ( A , cupy . ndarray ) ) : #NEWLINE# #INDENT# return cupy . array ( A , copy = True , ndmin = d ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# c = cupy . array ( A , copy = False , ndmin = d ) #NEWLINE# #UNINDENT# if ( d < c . ndim ) : #NEWLINE# #INDENT# tup = ( ( ( 1 , ) * ( c . ndim - d ) ) + tup ) #NEWLINE# #UNINDENT# shape_out = tuple ( ( ( s * t ) for ( s , t ) in zip ( c . shape , tup ) ) ) #NEWLINE# if ( c . size == 0 ) : #NEWLINE# #INDENT# return cupy . empty ( shape_out , dtype = c . dtype ) #NEWLINE# #UNINDENT# c_shape = [ ] #NEWLINE# ret_shape = [ ] #NEWLINE# for ( dim_in , nrep ) in zip ( c . shape , tup ) : #NEWLINE# #INDENT# if ( nrep == 1 ) : #NEWLINE# #INDENT# c_shape . append ( dim_in ) #NEWLINE# ret_shape . append ( dim_in ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( dim_in == 1 ) : #NEWLINE# #INDENT# c_shape . append ( dim_in ) #NEWLINE# ret_shape . append ( nrep ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# c_shape . append ( 1 ) #NEWLINE# c_shape . append ( dim_in ) #NEWLINE# ret_shape . append ( nrep ) #NEWLINE# ret_shape . append ( dim_in ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ret = cupy . empty ( ret_shape , dtype = c . dtype ) #NEWLINE# if ret . size : #NEWLINE# #INDENT# ret [ ... ] = c . reshape ( c_shape ) #NEWLINE# #UNINDENT# return ret . reshape ( shape_out )