code: def patch_device(model: nn.Module, device: str):
      device_holder = torch.jit.trace(
          lambda: torch.ones([]).to(torch.device(device)),
          example_inputs=[],
      )
      device_node = [
          n
          for n in device_holder.graph.findAllNodes("prim::Constant")
          if "Device" in repr(n)
      ][-1]
  
      def patch_dev(module):
          try:
              graphs = (
                  [module.graph] if hasattr(module, "graph") else []
              )
          except RuntimeError:
              graphs = []
  
          if hasattr(module, "forward1"):
              graphs.append(module.forward1.graph)
  
          for graph in graphs:
              for node in graph.findAllNodes("prim::Constant"):
                  if "value" in node.attributeNames() and str(
                      node["value"]
                  ).startswith("cuda"):
                      node.copyAttributes(device_node)
  
      model.apply(patch_dev)
      patch_dev(model.encode_image)
      patch_dev(model.encode_text)
  
file_path: towhee/towhee/models/clip/clip_utils.py
imports: from typing import Union, List, Dict
  from pkg_resources import packaging
  from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
  from torchvision.transforms import InterpolationMode
  import torch
  import torchvision
  from torch import nn
  from .simple_tokenizer import SimpleTokenizer
label_desc: Use image node_id 8 for calling a global function with example usage: patch_device(model, device) without return types