class_docstr: A basic negative sampler.
  
  This negative sampler that corrupts positive triples $(h,r,t) \in \mathcal{K}$ by replacing either $h$, $r$ or $t$
  based on the chosen corruption scheme. The corruption scheme can contain $h$, $r$ and $t$ or any subset of these.
  
  Steps:
  
  1. Randomly (uniformly) determine whether $h$, $r$ or $t$ shall be corrupted for a positive triple
     $(h,r,t) \in \mathcal{K}$.
  2. Randomly (uniformly) sample an entity $e \in \mathcal{E}$ or relation $r' \in \mathcal{R}$ for selection to
     corrupt the triple.
  
     - If $h$ was selected before, the corrupted triple is $(e,r,t)$
     - If $r$ was selected before, the corrupted triple is $(h,r',t)$
     - If $t$ was selected before, the corrupted triple is $(h,r,e)$
  3. If ``filtered`` is set to ``True``, all proposed corrupted triples that also exist as
     actual positive triples $(h,r,t) \in \mathcal{K}$ will be removed.
class_docstr_tok: ["A","basic","negative","sampler",".","This","negative","sampler","that","corrupts","positive","triples","$","(","h",",","r",",","t",")","\\in","\\mathcal","{","K","}","$","by","replacing","either","$","h","$",",","$","r","$","or","$","t","$","based","on","the","chosen","corruption","scheme",".","The","corruption","scheme","can","contain","$","h","$",",","$","r","$","and","$","t","$","or","any","subset","of","these",".","Steps",":","1",".","Randomly","(","uniformly",")","determine","whether","$","h","$",",","$","r","$","or","$","t","$","shall","be","corrupted","for","a","positive","triple","$","(","h",",","r",",","t",")","\\in","\\mathcal","{","K","}","$",".","2",".","Randomly","(","uniformly",")","sample","an","entity","$","e","\\in","\\mathcal","{","E","}","$","or","relation","$","r","'","\\in","\\mathcal","{","R","}","$","for","selection","to","corrupt","the","triple",".","-","If","$","h","$","was","selected","before",",","the","corrupted","triple","is","$","(","e",",","r",",","t",")","$","-","If","$","r","$","was","selected","before",",","the","corrupted","triple","is","$","(","h",",","r","'",",","t",")","$","-","If","$","t","$","was","selected","before",",","the","corrupted","triple","is","$","(","h",",","r",",","e",")","$","3",".","If","``","filtered","``","is","set","to","``","True","``",",","all","proposed","corrupted","triples","that","also","exist","as","actual","positive","triples","$","(","h",",","r",",","t",")","\\in","\\mathcal","{","K","}","$","will","be","removed","."]
docstr: Initialize the basic negative sampler with the given entities.
  
  :param corruption_scheme:
      What sides ('h', 'r', 't') should be corrupted. Defaults to head and tail ('h', 't').
  :param kwargs:
      Additional keyword based arguments passed to :class:`pykeen.sampling.NegativeSampler`.
docstr_tok: ["Initialize","the","basic","negative","sampler","with","the","given","entities",".",":","param","corruption_scheme",":","What","sides","(","'","h","'",",","'","r","'",",","'t","'",")","should","be","corrupted",".","Defaults","to","head","and","tail","(","'","h","'",",","'t","'",")",".",":","param","kwargs",":","Additional","keyword","based","arguments","passed","to",":","class",":","`","pykeen.sampling.NegativeSampler","`","."]
code: def __init__(
      self,
      *,
      corruption_scheme: Optional[Collection[Target]] = None,
      **kwargs,
  ) -> None:
      """Initialize the basic negative sampler with the given entities.
  
      :param corruption_scheme:
          What sides ('h', 'r', 't') should be corrupted. Defaults to head and tail ('h', 't').
      :param kwargs:
          Additional keyword based arguments passed to :class:`pykeen.sampling.NegativeSampler`.
      """
      super().__init__(**kwargs)
      self.corruption_scheme = corruption_scheme or (
          LABEL_HEAD,
          LABEL_TAIL,
      )
      # Set the indices
      self._corruption_indices = [
          TARGET_TO_INDEX[side] for side in self.corruption_scheme
      ]
  
file_path: pykeen/src/pykeen/sampling/basic_negative_sampler.py
imports: import math
  from typing import Collection, Optional
  import torch
  from .negative_sampler import NegativeSampler
  from ..constants import LABEL_HEAD, LABEL_TAIL, TARGET_TO_INDEX
  from ..typing import Target
label_desc: Use image node_id 1 to create a new BasicNegativeSampler object from inherited base classes: NegativeSampler with example: obj = BasicNegativeSampler()