code: def deteriorate(
      reference: TriplesFactory,
      *others: TriplesFactory,
      n: Union[int, float],
      random_state: TorchRandomHint = None,
  ) -> List[TriplesFactory]:
      """Remove n triples from the reference set.
  
      :param reference: The reference triples factory
      :param others: Other triples factories to deteriorate
      :param n: The ratio to deteriorate. If given as a float, should be between 0 and 1.
          If an integer, deteriorates that many triples
      :param random_state: The random state
      :returns: A concatenated list of the processed reference and other triples factories
      :raises NotImplementedError: if the reference triples factory has inverse triples
      :raises ValueError: If a float is given for n that isn't between 0 and 1
      """
      # TODO: take care that triples aren't removed that are the only ones with any given entity
      if reference.create_inverse_triples:
          raise NotImplementedError
  
      if isinstance(n, float):
          if n < 0 or 1 <= n:
              raise ValueError
          n = int(n * reference.num_triples)
  
      generator = ensure_torch_random_state(random_state)
      logger.debug("random state %s", random_state)
      logger.debug("generator %s %s", generator, generator.get_state())
      idx = torch.randperm(reference.num_triples, generator=generator)
      logger.debug("idx %s", idx)
      reference_idx, deteriorated_idx = idx.split(
          split_size=[reference.num_triples - n, n], dim=0
      )
  
      first = reference.clone_and_exchange_triples(
          mapped_triples=reference.mapped_triples[reference_idx],
      )
  
      # distribute the deteriorated triples across the remaining factories
      didxs = deteriorated_idx.split(math.ceil(n / len(others)), dim=0)
      rest = [
          tf.clone_and_exchange_triples(
              mapped_triples=(
                  torch.cat(
                      [
                          tf.mapped_triples,
                          reference.mapped_triples[didx],
                      ],
                      dim=0,
                  )
                  if didx is not None
                  else tf.mapped_triples  # maybe just give same tf? should it be copied?
              ),
          )
          for didx, tf in zip_longest(didxs, others)
      ]
  
      return [first, *rest]
  
file_path: pykeen/src/pykeen/triples/deteriorate.py
imports: import logging
  import math
  from itertools import zip_longest
  from typing import List, Union
  import click
  import more_click
  import torch
  from pykeen.triples import TriplesFactory
  from pykeen.typing import TorchRandomHint
  from pykeen.utils import ensure_torch_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: deteriorate(reference) and returns: list