class_docstr: :class:`KGSampler` is used to sample negative entities in a knowledge graph.
  
  Args:
      dataset (Dataset): The knowledge graph dataset, which contains triplets in a knowledge graph.
      distribution (str, optional): Distribution of the negative entities. Defaults to 'uniform'.
class_docstr_tok: [":","class",":","`","KGSampler","`","is","used","to","sample","negative","entities","in","a","knowledge","graph",".","Args",":","dataset","(","Dataset",")",":","The","knowledge","graph","dataset",",","which","contains","triplets","in","a","knowledge","graph",".","distribution","(","str",",","optional",")",":","Distribution","of","the","negative","entities",".","Defaults","to","'uniform","'","."]
code: def __init__(self, dataset, distribution="uniform", alpha=1.0):
      self.dataset = dataset
  
      self.hid_field = dataset.head_entity_field
      self.tid_field = dataset.tail_entity_field
      self.hid_list = dataset.head_entities
      self.tid_list = dataset.tail_entities
  
      self.head_entities = set(dataset.head_entities)
      self.entity_num = dataset.entity_num
  
      super().__init__(distribution=distribution, alpha=alpha)
  
imports: import copy
  import numpy
  from numpy.random import sample
  import torch
  from collections import Counter
label_desc: Use image node_id 1 to create a new KGSampler object from inherited base classes: AbstractSampler with example: obj = KGSampler(dataset, distribution, alpha)