def calc_pi_device(samples):
    x = randu(samples)
    y = randu(samples)
    return 4 * af.sum((x * x  + y * y) < 1) / samples

# Having the function outside is faster than the lambda inside
dataset/ETHPy150Open arrayfire/arrayfire-python/examples/benchmarks/monte_carlo_pi.py/calc_pi_device/original