code: def async_update(num_threads, model, queue):
      """Asynchronous embedding update for entity embeddings."""
      torch.set_num_threads(num_threads)
      print("async start")
      while True:
          (
              grad_u,
              grad_v,
              grad_v_neg,
              nodes,
              neg_nodes,
              first_flag,
          ) = queue.get()
          if grad_u is None:
              return
          with torch.no_grad():
              if first_flag:
                  model.fst_u_embeddings.weight.data.index_add_(
                      0, nodes[:, 0], grad_u
                  )
                  model.fst_u_embeddings.weight.data.index_add_(
                      0, nodes[:, 1], grad_v
                  )
                  if neg_nodes is not None:
                      model.fst_u_embeddings.weight.data.index_add_(
                          0, neg_nodes, grad_v_neg
                      )
              else:
                  model.snd_u_embeddings.weight.data.index_add_(
                      0, nodes[:, 0], grad_u
                  )
                  model.snd_v_embeddings.weight.data.index_add_(
                      0, nodes[:, 1], grad_v
                  )
                  if neg_nodes is not None:
                      model.snd_v_embeddings.weight.data.index_add_(
                          0, neg_nodes, grad_v_neg
                      )
  
imports: import random
  import numpy
  import torch
  import torch.multiprocessing
  import torch.nn
  import torch.nn.functional
  from torch.multiprocessing import Queue
  from torch.nn import init
label_desc: Use image node_id 3 for calling a global function with example usage: async_update(num_threads, model, queue) without return types