code: def _split_triples(
      mapped_triples: MappedTriples,
      sizes: Sequence[int],
      random_state: TorchRandomHint = None,
  ) -> Sequence[MappedTriples]:
      """
      Randomly split triples into groups of given sizes.
  
      :param mapped_triples: shape: (n, 3)
          The triples.
      :param sizes:
          The sizes.
      :param random_state:
          The random state for reproducible splits.
  
      :return:
          The splitted triples.
  
      :raises ValueError:
          If the given sizes are different from the number of triples in mapped triples
      """
      num_triples = mapped_triples.shape[0]
      if sum(sizes) != num_triples:
          raise ValueError(
              f"Received {num_triples} triples, but the sizes sum up to {sum(sizes)}"
          )
  
      # Split indices
      idx = torch.randperm(num_triples, generator=random_state)
      idx_groups = idx.split(split_size=sizes, dim=0)
  
      # Split triples
      triples_groups = [mapped_triples[idx] for idx in idx_groups]
      logger.info(
          "done splitting triples to groups of sizes %s",
          [triples.shape[0] for triples in triples_groups],
      )
  
      return triples_groups
  
imports: import logging
  import typing
  from abc import abstractmethod
  from typing import Collection, Optional, Sequence, Set, Tuple, Type, Union
  import numpy
  import pandas
  import torch
  from class_resolver.api import ClassResolver, HintOrType
  from ..constants import COLUMN_LABELS
  from ..typing import LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, MappedTriples, Target, TorchRandomHint
  from ..utils import ensure_torch_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: _split_triples(mapped_triples, sizes, random_state) and returns: triples_groups