class_docstr: A model which filters predictions by co-occurence.
  
  ---
  citation:
      author: Berrendorf
      year: 2022
      link: https://github.com/pykeen/pykeen/pull/943
      github: pykeen/pykeen
docstr: Initialize the model.
  
  :param triples_factory:
      the (training) triples factory; used for creating the co-occurrence counts *and* for instantiating the
      base model.
  :param additional_triples:
      additional triples to use for creating the co-occurrence statistics
  :param apply_in_training:
      whether to apply the masking also during training
  :param base:
      the base model, or a hint thereof.
  :param training_fill_value:
      the training fill value; for most loss functions, this has to be a finite value, i.e., not infinity
  :param inference_fill_value:
      the inference fill value
  :param conjunctive:
      whether to use conjuction or disjunction to combine non-filter masks
  :param kwargs:
      additional keyword-based parameters passed to the base model upon instantiation
docstr_tok: ["Initialize","the","model",".",":","param","triples_factory",":","the","(","training",")","triples","factory",";","used","for","creating","the","co-occurrence","counts","*","and","*","for","instantiating","the","base","model",".",":","param","additional_triples",":","additional","triples","to","use","for","creating","the","co-occurrence","statistics",":","param","apply_in_training",":","whether","to","apply","the","masking","also","during","training",":","param","base",":","the","base","model",",","or","a","hint","thereof",".",":","param","training_fill_value",":","the","training","fill","value",";","for","most","loss","functions",",","this","has","to","be","a","finite","value",",","i.e.",",","not","infinity",":","param","inference_fill_value",":","the","inference","fill","value",":","param","conjunctive",":","whether","to","use","conjuction","or","disjunction","to","combine","non-filter","masks",":","param","kwargs",":","additional","keyword-based","parameters","passed","to","the","base","model","upon","instantiation"]
code: def __init__(
      self,
      *,
      triples_factory: CoreTriplesFactory,
      additional_triples: Union[
          None, MappedTriples, List[MappedTriples]
      ] = None,
      apply_in_training: bool = False,
      base: HintOrType[Model] = "rotate",
      training_fill_value: float = -1.0e03,
      inference_fill_value: float = float("-inf"),
      conjunctive: bool = False,
      **kwargs,
  ) -> None:
      """
      Initialize the model.
  
      :param triples_factory:
          the (training) triples factory; used for creating the co-occurrence counts *and* for instantiating the
          base model.
      :param additional_triples:
          additional triples to use for creating the co-occurrence statistics
      :param apply_in_training:
          whether to apply the masking also during training
      :param base:
          the base model, or a hint thereof.
      :param training_fill_value:
          the training fill value; for most loss functions, this has to be a finite value, i.e., not infinity
      :param inference_fill_value:
          the inference fill value
      :param conjunctive:
          whether to use conjuction or disjunction to combine non-filter masks
      :param kwargs:
          additional keyword-based parameters passed to the base model upon instantiation
      """
      # avoid cyclic imports
      from .. import model_resolver
  
      # create base model
      base = model_resolver.make(
          base, triples_factory=triples_factory, pos_kwargs=kwargs
      )
  
      super().__init__(
          triples_factory=triples_factory,
          loss=base.loss,
          predict_with_sigmoid=base.predict_with_sigmoid,
          random_seed=base._random_seed,
      )
      # assign *after* nn.Module.__init__
      self.base = base
  
      # save constants
      self.conjunctive = conjunctive
      self.apply_in_training = apply_in_training
      self.training_fill_value = training_fill_value
      self.inference_fill_value = inference_fill_value
  
      # index triples
      mapped_triples = prepare_filter_triples(
          mapped_triples=triples_factory.mapped_triples,
          additional_filter_triples=additional_triples,
          warn=False,
      ).numpy()
      nums = [
          triples_factory.num_entities,
          triples_factory.num_relations,
          triples_factory.num_entities,
      ]
      self.indexes = {
          col_label: {
              row_label: get_csr_matrix(
                  row_indices=mapped_triples[:, row_index],
                  col_indices=mapped_triples[:, col_index],
                  shape=(num_rows, num_cols),
                  dtype=bool,
                  norm=None,
              )
              for num_rows, (row_label, row_index) in zip(
                  nums, TARGET_TO_INDEX.items()
              )
              if row_label != col_label
          }
          for num_cols, (col_label, col_index) in zip(
              nums, TARGET_TO_INDEX.items()
          )
      }
  
      # initialize base model's parameters
      self.reset_parameters_()
  
imports: from typing import Any, ClassVar, List, Mapping, Optional, Union
  import scipy.sparse
  import torch
  from class_resolver import HintOrType
  from docdata import parse_docdata
  from ..base import Model
  from ..baseline.utils import get_csr_matrix
  from ...constants import TARGET_TO_INDEX
  from ...triples.triples_factory import CoreTriplesFactory
  from ...typing import LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, InductiveMode, MappedTriples, Target
  from ...utils import prepare_filter_triples
label_desc: Use image node_id 1 to create a new CooccurrenceFilteredModel object from inherited base classes: Model with example: obj = CooccurrenceFilteredModel()