class_docstr: Test the basic negative sampler.
class_docstr_tok: ["Test","the","basic","negative","sampler","."]
docstr: Test if relations and half of heads and tails are not corrupted.
docstr_tok: ["Test","if","relations","and","half","of","heads","and","tails","are","not","corrupted","."]
code: def test_sample_basic(self):
      """Test if relations and half of heads and tails are not corrupted."""
      negative_batch, batch_filter = self.instance.sample(
          positive_batch=self.positive_batch
      )
  
      # Test that half of the subjects and half of the objects are corrupted
      positive_batch = self.positive_batch.unsqueeze(dim=1)
      num_triples = negative_batch[..., 0].numel()
      half_size = num_triples // 2
      num_subj_corrupted = (
          positive_batch[..., 0] != negative_batch[..., 0]
      ).sum()
      num_obj_corrupted = (
          positive_batch[..., 2] != negative_batch[..., 2]
      ).sum()
      assert num_obj_corrupted - 1 <= num_subj_corrupted
      assert num_subj_corrupted - 1 <= num_obj_corrupted
      assert num_subj_corrupted - 1 <= num_triples
      assert half_size - 1 <= num_subj_corrupted
  
imports: import numpy.testing
  import torch
  import unittest_templates
  from pykeen.sampling import BasicNegativeSampler, BernoulliNegativeSampler, NegativeSampler, PseudoTypedNegativeSampler
  from pykeen.sampling.pseudo_type import create_index
  from tests.test_sampling import cases
label_desc: Use image node_id 1 for calling the BasicNegativeSamplerTest obj's underlying member method code with example usage: obj.test_sample_basic() without return types