code: def triples_factory_to_sparse_matrices(
      triples_factory: CoreTriplesFactory,
  ) -> Tuple[scipy.sparse.spmatrix, scipy.sparse.spmatrix]:
      """Compute relation representations as sparse matrices of entity pairs.
  
      .. note ::
          Both sets, head-tail-set, tail-head-set, have to be created at once since they need to share the same entity
          pair to Id mapping.
  
      :param triples_factory:
          The triples factory.
  
      :return: shape: (num_relations, num_entity_pairs)
          head-tail-set, tail-head-set matrices as {0, 1} integer matrices.
      """
      return mapped_triples_to_sparse_matrices(
          triples_factory.mapped_triples,
          num_relations=triples_factory.num_relations,
      )
  
imports: import logging
  from typing import Collection, Iterable, List, Mapping, Optional, Set, Tuple, TypeVar, Union, cast
  import click
  import numpy
  import scipy.sparse
  import torch
  from pykeen.datasets.base import EagerDataset
  from pykeen.triples.triples_factory import CoreTriplesFactory, TriplesFactory, cat_triples
  from pykeen.typing import MappedTriples
  from pykeen.utils import compact_mapping, get_connected_components
label_desc: Use image node_id 3 for calling a global function with example usage: triples_factory_to_sparse_matrices(triples_factory) and returns: mapped_triples_to_sparse_matrices