code: def _subset_interactions(
      interactions: BaseInteractions, idxs: Iterable[int]
  ) -> Union[ExplicitInteractions, Interactions]:
      idxs = np.array(idxs)
  
      coo_mat = coo_matrix(
          (
              interactions.mat.data[idxs],
              (interactions.mat.row[idxs], interactions.mat.col[idxs]),
          ),
          shape=(interactions.num_users, interactions.num_items),
      )
  
      # disable all ``Interactions`` checks for the data splits, since we assume the initial
      # ``Interactions`` object would have these checks already applied prior to the data split
      if isinstance(interactions, Interactions):
          return Interactions(
              mat=coo_mat,
              num_negative_samples=interactions.num_negative_samples,
              allow_missing_ids=True,
              remove_duplicate_user_item_pairs=False,
              num_users=interactions.num_users,
              num_items=interactions.num_items,
              check_num_negative_samples_is_valid=False,
              max_number_of_samples_to_consider=interactions.max_number_of_samples_to_consider,
              seed=interactions.seed,
          )
      else:
          return ExplicitInteractions(
              mat=coo_mat,
              allow_missing_ids=True,
              remove_duplicate_user_item_pairs=False,
              num_users=interactions.num_users,
              num_items=interactions.num_items,
          )
  
file_path: collie/collie/cross_validation.py
imports: from collections import defaultdict
  import functools
  import operator
  from typing import Any, Iterable, Optional, Tuple, Union
  from joblib import delayed, Parallel
  import numpy
  from scipy.sparse import coo_matrix
  from sklearn.model_selection import train_test_split
  from collie.interactions import BaseInteractions, ExplicitInteractions, HDF5Interactions, Interactions
  from collie.utils import get_random_seed
label_desc: Use image node_id 1 for calling a global function with example usage: _subset_interactions(interactions, idxs) and returns: Interactions, ExplicitInteractions