def test_scan_vmap_collectives(self):

    def scan_f(state, x):
        s = (lax.psum(state, 'i') * x)
        return (state, s)

    def scan(state, xs):
        return lax.scan(scan_f, state, xs)
    scan_v = api.vmap(scan, in_axes=0, out_axes=0, axis_name='i')
    self.assertAllClose(scan_v(jnp.ones([1]), jnp.arange(5).reshape((1, 5))), (jnp.array([1.0]), jnp.array([[0.0, 1.0, 2.0, 3.0, 4.0]])))
def test_scan_vmap_collectives(self):

    def scan_f(state, x):
        s = (lax.psum(state, 'i') * x)
        return (state, s)

    def scan(state, xs):
        return lax.scan(scan_f, state, xs)
    scan_v = api.vmap(scan, in_axes=0, out_axes=0, axis_name='i')
    self.assertAllClose(scan_v(jnp.ones([1]), jnp.arange(5).reshape((1, 5))), (jnp.array([1.0]), jnp.array([[0.0, 1.0, 2.0, 3.0, 4.0]])))