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
code: def _mask(
      self,
      scores: torch.FloatTensor,
      batch: torch.LongTensor,
      target: Target,
      in_training: bool,
  ) -> torch.FloatTensor:
      if in_training and not self.apply_in_training:
          return scores
      fill_value = (
          self.training_fill_value
          if in_training
          else self.inference_fill_value
      )
      # get masks, shape: (batch_size, num_entities/num_relations)
      first_mask, second_mask = [
          index[batch_indices.cpu().numpy()]
          for batch_indices, (_target, index) in zip(
              batch.t(),
              sorted(
                  self.indexes[target].items(),
                  key=lambda kv: TARGET_TO_INDEX[kv[0]],
              ),
          )
      ]
      # combine masks
      # note: * is an elementwise and, and + and elementwise or
      mask = (
          (first_mask * second_mask)
          if self.conjunctive
          else (first_mask + second_mask)
      )
      # get non-zero entries
      rows, cols = [
          torch.as_tensor(ind, device=scores.device, dtype=torch.long)
          for ind in mask.nonzero()
      ]
      # set scores for fill value for every non-occuring entry
      new_scores = scores.new_full(
          size=scores.shape, fill_value=fill_value
      )
      new_scores[rows, cols] = scores[rows, cols]
      return new_scores
  
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 2 for calling the CooccurrenceFilteredModel obj's underlying member method code with example usage: obj._mask(scores, batch, target, in_training) and returns: new_scores, scores