code: def use_cuquantum(optimize="auto-hq"):
      """Plugin to use `cuQuantum <https://developer.nvidia.com/cuquantum-sdk>`_ to precompute (and cache) a better contraction path
  
      Examples
      --------
      >>> import tensorly as tl
  
      Use your favourite backend, here PyTorch:
  
      >>> tl.set_backend('pytorch')
  
      Use the convenient backend system to automatically dispatch all tenalg operations to einsum
  
      >>> from tensorly import tenalg
      >>> tenalg.set_backend('einsum')
  
      Now you can transparently cache the optimal contraction path, transparently:
  
      >>> from tensorly import plugins
      >>> plugins.use_cuquantum()
  
      That's it! Now opt-einsum will be used for finding an (near) optimal contraction path
      and cuQuantum will be used to actually perform the tensor contractions!
  
      You can revert to the original einsum just as easily:
  
      >>> plugings.use_default_einsum()
  
      Revert to the original tensor algebra backend:
  
      >>> tenalg.set_backend('core')
      """
      global PREVIOUS_EINSUM
      global CUQUANTUM_HANDLE
  
      # Import opt-einsum for the contraction path
      try:
          import opt_einsum as oe
      except ImportError as error:
          message = (
              "Impossible to import opt-einsum.\n"
              "First install it:\n"
              "conda install opt_einsum -c conda-forge\n"
              " or pip install opt_einsum"
          )
          raise ImportError(message) from error
  
      # Import cuQuantum for the actual contraction
      try:
          import cuquantum
      except ImportError as error:
          message = (
              "Impossible to import cuquantum.\n"
              "First install it:\n"
              "conda install -c conda-forge cuquantum-python\n"
              " or pip install cuquantum-python"
          )
          raise ImportError(message) from error
  
      if CUQUANTUM_HANDLE is None:
          CUQUANTUM_HANDLE = cuquantum.cutensornet.create()
  
      def cached_einsum(equation, *args):
          shapes = [tl.shape(arg) for arg in args]
          key = equation + "," + ",".join(f"{s}" for s in shapes)
          try:
              path = CUQUANTUM_PATH_CACHE[key]
          except KeyError:
              path, _ = oe.contract_path(
                  equation, *args, optimize=optimize
              )
              CUQUANTUM_PATH_CACHE[key] = path
  
          network = cuquantum.Network(
              equation, *args, options={"handle": CUQUANTUM_HANDLE}
          )
          network.contract_path(optimize={"path": path})
          return network.contract()
  
          # return cuquantum.contract(equation, *args, optimize={'path': path})
  
      if PREVIOUS_EINSUM is None:
          PREVIOUS_EINSUM = tl.backend.current_backend().einsum
  
      tl.backend.BackendManager.register_backend_method(
          "einsum", cached_einsum
      )
  
imports: import tensorly
label_desc: Use image node_id 3 for calling a global function with example usage: use_cuquantum(optimize) and returns: network