def _get_stream(device: int):
        r"""
        Gets a background stream for copying between CPU and XPU.
        """
        global _streams
        if device == -1:
            return None
        if _streams is None:
            _streams = [None] * torch.xpu.device_count()
        if _streams[device] is None:
            _streams[device] = torch.xpu.Stream(device)
        return _streams[device]

        Gets a background stream for copying between CPU and XPU.
        
intel_extension_for_pytorch/xpu/overrides.py