class_docstr: A sampler that accounts for which entities co-occur with a relation.
  
  To generate a corrupted head entity for triple $(h, r, t)$, only those entities are considered which occur as a
  head entity in a triple with the relation $r$.
  
  .. warning:: With this type of sampler, filtering for false negatives is more important.
code: def corrupt_batch(
      self, positive_batch: torch.LongTensor
  ):  # noqa: D102
      batch_size = positive_batch.shape[0]
  
      # shape: (batch_size, num_neg_per_pos, 3)
      negative_batch = positive_batch.unsqueeze(dim=1).repeat(
          1, self.num_negs_per_pos, 1
      )
  
      # Uniformly sample from head/tail offsets
      r = positive_batch[:, 1]
      start_heads = self.offsets[2 * r].unsqueeze(dim=-1)
      start_tails = self.offsets[2 * r + 1].unsqueeze(dim=-1)
      end = self.offsets[2 * r + 2].unsqueeze(dim=-1)
      num_choices = end - start_heads
      negative_ids = (
          start_heads
          + (
              torch.rand(size=(batch_size, self.num_negs_per_pos))
              * num_choices
          ).long()
      )
  
      # get corresponding entity
      entity_id = self.data[negative_ids]
  
      # and position within triple (0: head, 2: tail)
      triple_position = 2 * (negative_ids >= start_tails).long()
  
      # write into negative batch
      negative_batch[
          torch.arange(
              batch_size, device=negative_batch.device
          ).unsqueeze(dim=-1),
          torch.arange(
              self.num_negs_per_pos, device=negative_batch.device
          ).unsqueeze(dim=0),
          triple_position,
      ] = entity_id
  
      return negative_batch
  
file_path: pykeen/src/pykeen/sampling/pseudo_type.py
imports: import itertools
  import logging
  from typing import Tuple
  import torch
  from .negative_sampler import NegativeSampler
  from ..typing import MappedTriples
  from ..utils import create_relation_to_entity_set_mapping
label_desc: Use image node_id 2 for calling the PseudoTypedNegativeSampler obj's underlying member method code with example usage: obj.corrupt_batch(positive_batch) and returns: negative_batch