def _get_stream(device):
    """Gets a background stream for copying between CPU and GPU"""
    global _streams
    if device == -1:
        return None
    if _streams is None:
        _streams = [None] * cuda.device_count()
    if _streams[device] is None: _streams[device] = cuda.Stream(device)
    return _streams[device]
Gets a background stream for copying between CPU and GPU
third-party/lama/models/ade20k/segm_lib/nn/parallel/data_parallel.py