class_docstr: Sparse Embedding for Knowledge Graph
  It is used to store both entity embeddings and relation embeddings.
  
  Parameters
  ----------
  args :
      Global configs.
  num : int
      Number of embeddings.
  dim : int
      Embedding dimention size.
  device : th.device
      Device to store the embedding.
docstr: Return sliced tensor.
  
  Parameters
  ----------
  idx : th.tensor
      Slicing index
  gpu_id : int
      Which gpu to put sliced data in.
  trace : bool
      If True, trace the computation. This is required in training.
      If False, do not trace the computation.
      Default: True
docstr_tok: ["Return","sliced","tensor",".","Parameters","--","--","--","--","--","idx",":","th.tensor","Slicing","index","gpu_id",":","int","Which","gpu","to","put","sliced","data","in",".","trace",":","bool","If","True",",","trace","the","computation",".","This","is","required","in","training",".","If","False",",","do","not","trace","the","computation",".","Default",":","True"]
code: def __call__(self, idx, gpu_id=-1, trace=True):
      """Return sliced tensor.
  
      Parameters
      ----------
      idx : th.tensor
          Slicing index
      gpu_id : int
          Which gpu to put sliced data in.
      trace : bool
          If True, trace the computation. This is required in training.
          If False, do not trace the computation.
          Default: True
      """
      if self.is_feat:
          assert not trace
      if self.has_cross_rel:
          cpu_idx = idx.cpu()
          cpu_mask = self.cpu_bitmap[cpu_idx]
          cpu_idx = cpu_idx[cpu_mask]
          cpu_idx = th.unique(cpu_idx)
          if cpu_idx.shape[0] != 0:
              cpu_emb = self.global_emb.emb[cpu_idx]
              self.emb[cpu_idx] = cpu_emb.cuda(gpu_id)
      if self.is_feat:
          assert not trace
          s = th.from_numpy(self.emb[idx.numpy()]).to(th.float)
      else:
          s = self.emb[idx]
      if gpu_id >= 0:
          s = s.cuda(gpu_id)
      # During the training, we need to trace the computation.
      # In this case, we need to record the computation path and compute the gradients.
      if trace:
          data = s.clone().detach().requires_grad_(True)
          self.trace.append((idx, data))
      else:
          data = s
      return data
  
imports: import os
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.nn.init
  import torch.multiprocessing
  from torch.multiprocessing import Queue
  from _thread import start_new_thread
  import traceback
  from functools import wraps
  from ..None import *
label_desc: Use image node_id 6 for calling the ExternalEmbedding obj's underlying member method code with example usage: obj.__call__(idx, gpu_id, trace) and returns: data