def astype ( array , y ) : if isinstance ( y , autograd . core . Node ) : return array . astype ( numpy . array ( y . value ) . dtype ) return array . astype ( numpy . array ( y ) . dtype )
python, how to apply astype function
A functional form of the astype method .
def astype(array, y):
  """A functional form of the `astype` method.

  Args:
    array: The array or number to cast.
    y: An array or number, as the input, whose type should be that of array.

  Returns:
    An array or number with the same dtype as `y`.
  """
  if isinstance(y, autograd.core.Node):
    return array.astype(numpy.array(y.value).dtype)
  return array.astype(numpy.array(y).dtype)