def METHOD_NAME(modname, recorded):
    m = get_module(modname)
    dr.set_flag(dr.JitFlag.VCallRecord, recorded)
    def f(a, b):
        return a * 4.0, b
    def g(a, b):
        return a * 8.0, -b
    idx = m.UInt([0, 0, 1, 1])
    a = m.Float([1.0, 2.0, 3.0, 4.0])
    b = m.Float(1.0)
    dr.enable_grad(a, b)
    result = dr.switch(idx, [f, g], a, b)
    assert dr.allclose(result, [[4, 8, 24, 32], [1, 1, -1, -1]])
    dr.forward(a)
    grad = dr.grad(result)
    assert dr.allclose(grad, [[4, 4, 8, 8], [0, 0, 0, 0]])