code: def _get_labels(
      targets: csr_matrix,
      user_ids: Union[np.array, torch.tensor],
      preds: Union[np.array, torch.tensor],
      device: str,
  ) -> torch.tensor:
      """
      Returns a binary array indicating which of the recommended products are in each user's target
      set.
  
      Parameters
      ----------
      targets: scipy.sparse.csr_matrix
          Interaction matrix containing user and item IDs
      user_ids: np.array or torch.tensor
          Users corresponding to the recommendations in the top k predictions
      preds: torch.tensor
          Top ``k`` item IDs to recommend to each user of shape (n_users x k)
      device: string
          Device torch should use
  
      Returns
      -------
      labels: torch.tensor
          Tensor with the same dimensions as input ``preds``
  
      """
      return torch.tensor(
          (
              targets[user_ids[:, None], np.array(preds.detach().cpu())]
              > 0
          )
          .astype("double")
          .toarray(),
          requires_grad=False,
          device=device,
      )
  
imports: from typing import Any, Callable, Iterable, List, Optional, Tuple, Union
  import warnings
  import numpy
  from scipy.sparse import csr_matrix
  import torch
  from torchmetrics import Metric
  from torchmetrics.functional import auroc
  from tqdm.auto import tqdm
  import collie
  from collie.interactions import ExplicitInteractions, Interactions, InteractionsDataLoader
  from collie.model import BasePipeline
label_desc: Use image node_id 3 for calling a global function with example usage: _get_labels(targets, user_ids, preds, device) and returns: torch