code: def attach_parallels(uuid, vid_hex=None, pid_hex=None, serial=None):
      usb_devices = json.loads(
          subprocess.check_output(
              ["prlsrvctl", "usb", "list", "-j"], encoding="utf-8"
          )
      )
      for dev in usb_devices:
          _, dev_vid_hex, dev_pid_hex, _, _, dev_serial = dev[
              "System name"
          ].split("|")
          dev_vid_hex = dev_vid_hex.lower()
          dev_pid_hex = dev_pid_hex.lower()
          if (
              vid_hex == dev_vid_hex
              and pid_hex == dev_pid_hex
              and (serial is None or serial == dev_serial)
          ):
              subprocess.check_call(
                  ["prlsrvctl", "usb", "set", dev["Name"], uuid]
              )
              if "Used-By-Vm-Name" in dev:
                  subprocess.check_call(
                      [
                          "prlctl",
                          "set",
                          dev["Used-By-Vm-Name"],
                          "--device-disconnect",
                          dev["Name"],
                      ]
                  )
              subprocess.check_call(
                  [
                      "prlctl",
                      "set",
                      uuid,
                      "--device-connect",
                      dev["Name"],
                  ]
              )
              return
  
      raise Exception(
          f"Device with vid={vid_hex}, pid={pid_hex}, serial={serial!r} not found:\n{usb_devices!r}"
      )
  
imports: import argparse
  import copy
  import json
  import logging
  import pathlib
  import os
  import re
  import shlex
  import shutil
  import subprocess
  import sys
  import pathlib
label_desc: Use image node_id 4 for calling a global function with example usage: attach_parallels(uuid, vid_hex, pid_hex, serial) without return types