def result_type(arr1, arr2):
    x1 = arr1.flat[0]
x2 = arr2.flat[0]
return (x1 * x2).dtype

def array_operation(arr1, arr2):
    return np.empty(arr1.shape, result_type(arr1, arr2))
Getting the dtype of a result array in numpy