<s> import numpy <EOL> import cupy <EOL> def bincount ( x , weights = None , minlength = None ) : <EOL> """<STR_LIT>""" <EOL> if x . ndim > <NUM_LIT:1> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if x . ndim < <NUM_LIT:1> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if x . dtype . kind == '<STR_LIT:f>' : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> if ( x < <NUM_LIT:0> ) . any ( ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if weights is not None and x . shape != weights . shape : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if minlength is not None : <EOL> minlength = int ( minlength ) <EOL> if minlength <= <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> size = int ( cupy . max ( x ) ) + <NUM_LIT:1> <EOL> if minlength is not None : <EOL> size = max ( size , minlength ) <EOL> if weights is None : <EOL> b = cupy . zeros ( ( size , ) , dtype = cupy . int32 ) <EOL> cupy . ElementwiseKernel ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) ( x , b ) <EOL> b = b . astype ( numpy . intp ) <EOL> else : <EOL> b = cupy . zeros ( ( size , ) , dtype = cupy . float32 ) <EOL> cupy . ElementwiseKernel ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) ( x , weights , b ) <EOL> b = b . astype ( cupy . float64 ) <EOL> return b </s>
