class_docstr: A negative sampler.
class_docstr_tok: ["A","negative","sampler","."]
docstr: Initialize the negative sampler with the given entities.
  
  :param mapped_triples:
      the positive training triples
  :param num_entities:
      the number of entities. If None, will be inferred from the triples.
  :param num_relations:
      the number of relations. If None, will be inferred from the triples.
  :param num_negs_per_pos:
      number of negative samples to make per positive triple. Defaults to 1.
  :param filtered: Whether proposed corrupted triples that are in the training data should be filtered.
      Defaults to False. See explanation in :func:`filter_negative_triples` for why this is
      a reasonable default.
  :param filterer: If filtered is set to True, this can be used to choose which filter module from
      :mod:`pykeen.sampling.filtering` is used.
  :param filterer_kwargs:
      Additional keyword-based arguments passed to the filterer upon construction.
docstr_tok: ["Initialize","the","negative","sampler","with","the","given","entities",".",":","param","mapped_triples",":","the","positive","training","triples",":","param","num_entities",":","the","number","of","entities",".","If","None",",","will","be","inferred","from","the","triples",".",":","param","num_relations",":","the","number","of","relations",".","If","None",",","will","be","inferred","from","the","triples",".",":","param","num_negs_per_pos",":","number","of","negative","samples","to","make","per","positive","triple",".","Defaults","to","1.",":","param","filtered",":","Whether","proposed","corrupted","triples","that","are","in","the","training","data","should","be","filtered",".","Defaults","to","False",".","See","explanation","in",":","func",":","`","filter_negative_triples","`","for","why","this","is","a","reasonable","default",".",":","param","filterer",":","If","filtered","is","set","to","True",",","this","can","be","used","to","choose","which","filter","module","from",":","mod",":","`","pykeen.sampling.filtering","`","is","used",".",":","param","filterer_kwargs",":","Additional","keyword-based","arguments","passed","to","the","filterer","upon","construction","."]
code: def __init__(
      self,
      *,
      mapped_triples: MappedTriples,
      num_entities: Optional[int] = None,
      num_relations: Optional[int] = None,
      num_negs_per_pos: Optional[int] = None,
      filtered: bool = False,
      filterer: HintOrType[Filterer] = None,
      filterer_kwargs: Optional[Mapping[str, Any]] = None,
  ) -> None:
      """Initialize the negative sampler with the given entities.
  
      :param mapped_triples:
          the positive training triples
      :param num_entities:
          the number of entities. If None, will be inferred from the triples.
      :param num_relations:
          the number of relations. If None, will be inferred from the triples.
      :param num_negs_per_pos:
          number of negative samples to make per positive triple. Defaults to 1.
      :param filtered: Whether proposed corrupted triples that are in the training data should be filtered.
          Defaults to False. See explanation in :func:`filter_negative_triples` for why this is
          a reasonable default.
      :param filterer: If filtered is set to True, this can be used to choose which filter module from
          :mod:`pykeen.sampling.filtering` is used.
      :param filterer_kwargs:
          Additional keyword-based arguments passed to the filterer upon construction.
      """
      super().__init__()
      self.num_entities = (
          num_entities or mapped_triples[:, [0, 2]].max().item() + 1
      )
      self.num_relations = (
          num_relations or mapped_triples[:, 1].max().item() + 1
      )
      self.num_negs_per_pos = (
          num_negs_per_pos if num_negs_per_pos is not None else 1
      )
      self.filterer = (
          filterer_resolver.make(
              filterer,
              pos_kwargs=filterer_kwargs,
              mapped_triples=mapped_triples,
          )
          if filterer is not None or filtered
          else None
      )
  
file_path: pykeen/src/pykeen/sampling/negative_sampler.py
imports: from abc import abstractmethod
  from typing import Any, ClassVar, Mapping, Optional, Tuple
  import torch
  from class_resolver import HintOrType, normalize_string
  from torch import nn
  from .filtering import Filterer, filterer_resolver
  from ..typing import MappedTriples
label_desc: Use image node_id 1 to create a new NegativeSampler object from inherited base classes: nn with example: obj = NegativeSampler()