code: def patch_cuda(disable_jit: bool = True):
      """
      patch_cuda is used to make users' application that is written for cuda only
      runnable on a CPU device by one-line patching.
  
      e.g.
          >>> from bigdl.nano.pytorch.patching import patch_cuda
          >>> patch_cuda()  # be sure it is used at the header of the application
          >>> # all other cuda only codes will be avilable for cpu
  
      :param disable_jit: bool, if to disable jit compile. This is a known issue
             for patch_cuda function. jit compile has not been supported for some
             of the patching. Users may change it to False to check if their application
             is affected by this issue.
      """
      global is_cuda_patched
      if is_cuda_patched:
          return
  
      # add this parameter since it's a known issue
      if disable_jit:
          warning(
              "This CUDA patch is incompatible with JIT, JIT will be disabled!"
          )
          torch.jit._state.disable()
  
      replace_attr(torch.Tensor, "cuda", cuda)
      replace_attr(torch.Tensor, "to", to(torch.Tensor.to))
      replace_attr(torch.nn.Module, "cuda", cuda)
      replace_attr(torch.nn.Module, "to", to(torch.nn.Module.to))
      replace_attr(torch, "device", DeviceClass)
      replace_attr(torch, "load", load(torch.load))
      replace_attr(torch.cuda, "Stream", no_op_context)
      replace_attr(torch.cuda, "current_stream", current_stream)
      replace_attr(torch.Tensor, "record_stream", np_op_func)
      if not TORCH_VERSION_LESS_1_10:
          replace_attr(torch, "autocast", new_autocast)
          replace_attr(
              torch.cuda.amp, "autocast", torch.cpu.amp.autocast
          )
      replace_attr(
          torch.cuda.amp,
          "GradScaler",
          GradScalerClass_wrapper(torch.cuda.amp.GradScaler),
      )
      replace_attr(
          torch.distributed,
          "init_process_group",
          init_process_group(torch.distributed.init_process_group),
      )
      for no_op_cand in TORCH_CUDA_NO_OP_LIST:
          replace_attr(torch.cuda, no_op_cand, np_op_func)
      for t in COMMON_TENSOR_TYPE:
          replace_attr(
              torch.cuda, f"{t}Tensor", getattr(torch, f"{t}Tensor")
          )
      for f in CREATE_TENSOR_FUNC:
          try:
              replace_attr(
                  torch, f, create_tensor_func(getattr(torch, f))
              )
          except AttributeError:
              pass
  
      is_cuda_patched = True
  
imports: import os
  import torch
  from logging import warning
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_10
label_desc: Use image node_id 11 for calling a global function with example usage: patch_cuda(disable_jit) without return types