class_docstr: Dataset for knowledge graphs
  
  Args:
      triplets (list of tuples or 2D numpy.ndarray):
          The collection of training triplets (h, r, t) with shape [num_triplets, 3].
      num_ents (int):
          The number of entities in the knowledge graph.
      args (argparse.Namespace):
          Arguments of negative sampling, including:
          - neg_sample_size (int): Number of negative samples for each triplet.
          - neg_sample_type (str): The strategy used for negative sampling.
              'batch': sampling from current batch.
              'full': sampling from all entities.
              'chunk': triplets are divided into X chunks and each chunk shares
                  a group of negative samples sampled from all entities.
          - filter_sample (bool): Whether filter out existing triplets.
      filter_dict (dict, optional):
          Dictionary of existing triplets, in the form of
          {'head': {(t, r):set(h)}, 'tail': {(h, r):set(t)}}.
          Default to None.
      shared_path (dict, optional):
          Dictionary of shared embeddings' path for embedding prefetch
          in the form of {'ent': ent_path, 'rel': rel_path}.
          Default to None.
class_docstr_tok: ["Dataset","for","knowledge","graphs","Args",":","triplets","(","list","of","tuples","or","2D","numpy.ndarray",")",":","The","collection","of","training","triplets","(","h",",","r",",","t",")","with","shape","[","num_triplets",",","3","]",".","num_ents","(","int",")",":","The","number","of","entities","in","the","knowledge","graph",".","args","(","argparse.Namespace",")",":","Arguments","of","negative","sampling",",","including",":","-","neg_sample_size","(","int",")",":","Number","of","negative","samples","for","each","triplet",".","-","neg_sample_type","(","str",")",":","The","strategy","used","for","negative","sampling",".","'batch","'",":","sampling","from","current","batch",".","'full","'",":","sampling","from","all","entities",".","'chunk","'",":","triplets","are","divided","into","X","chunks","and","each","chunk","shares","a","group","of","negative","samples","sampled","from","all","entities",".","-","filter_sample","(","bool",")",":","Whether","filter","out","existing","triplets",".","filter_dict","(","dict",",","optional",")",":","Dictionary","of","existing","triplets",",","in","the","form","of","{","'head","'",":","{","(","t",",","r",")",":","set","(","h",")","}",",","'tail","'",":","{","(","h",",","r",")",":","set","(","t",")","}","}",".","Default","to","None",".","shared_path","(","dict",",","optional",")",":","Dictionary","of","shared","embeddings","'","path","for","embedding","prefetch","in","the","form","of","{","'ent","'",":","ent_path",",","'rel","'",":","rel_path","}",".","Default","to","None","."]
docstr: Sampling negative samples uniformly.
  
  Args:
      k (int): Number of sampled elements.
      cand (list or int): The list of elements to sample. The int
          value X denotes sampling integers from [0, X).
      filter_set (list): The list of invalid int values.
docstr_tok: ["Sampling","negative","samples","uniformly",".","Args",":","k","(","int",")",":","Number","of","sampled","elements",".","cand","(","list","or","int",")",":","The","list","of","elements","to","sample",".","The","int","value","X","denotes","sampling","integers","from","[","0",",","X",")",".","filter_set","(","list",")",":","The","list","of","invalid","int","values","."]
code: def uniform_sampler(k, cand, filter_set=None):
      """
      Sampling negative samples uniformly.
  
      Args:
          k (int): Number of sampled elements.
          cand (list or int): The list of elements to sample. The int
              value X denotes sampling integers from [0, X).
          filter_set (list): The list of invalid int values.
      """
      rng = default_rng()
      if filter_set is not None:
          new_e_list = []
          new_e_num = 0
          while new_e_num < k:
              new_e = rng.choice(cand, 2 * k, replace=True)
              mask = np.in1d(new_e, filter_set, invert=True)
              new_e = new_e[mask]
              new_e_list.append(new_e)
              new_e_num += len(new_e)
          new_e = np.concatenate(new_e_list)[:k]
      else:
          new_e = rng.choice(cand, k, replace=True)
      return new_e
  
imports: import os
  import numpy
  from numpy.random import default_rng
  import paddle
  from paddle.io import Dataset
  from paddle.io import DataLoader, DistributedBatchSampler
  from utils import timer_wrapper
label_desc: Use image node_id 8 for calling the KGDataset obj's underlying member method code with example usage: obj.uniform_sampler(k, cand, filter_set) and returns: new_e