Return a context manager appropriate for the given exuction mode.
If mode is “gpu”, then a specific device id may be provided to specify the GPU onto which kernel launches should be spawned.