class_docstr: PyTorch ``Dataset`` for implicit user-item interactions data.
  
  If ``mat`` is provided, the ``Interactions`` instance will act as a wrapper for a sparse matrix
  in COOrdinate format, typically looking like:
  
  * Users comprising the rows
  
  * Items comprising the columns
  
  * Ratings given by that user for that item comprising the elements of the matrix
  
  ``Interactions`` can be instantiated instead by passing in single arrays with corresponding
  user_ids, item_ids, and ratings (by default, set to 1 for implicit recommenders) values with
  the same functionality as a matrix. Note that with this approach, the number of users and items
  will be the maximum values in those two columns, respectively, and it is expected that all
  integers between 0 and the maximum ID should appear somewhere in the data.
  
  By default, exact negative sampling will be used during each ``__getitem__`` call. To use
  approximate negative sampling, set ``max_number_of_samples_to_consider = 0``. This will avoid
  building a positive item lookup dictionary during initialization.
  
  Unlike in ``ExplicitInteractions``, we rely on negative sampling for implicit data. Each
  ``__getitem__`` call will thus return a nested tuple containing user IDs, item IDs, and
  sampled negative item IDs. This nested vs. non-nested structure is key for the model to
  determine where it should be implicit or explicit. Use the table below for reference:
  
  .. list-table::
      :header-rows: 1
  
      * - ``__getitem__`` Format
        - Expected Meaning
        - Model Type
      * - ``((X, Y), Z)``
        - ``((user IDs, item IDs), negative item IDs)``
        - **Implicit**
      * - ``(X, Y, Z)``
        - ``(user IDs, item IDs, ratings)``
        - **Explicit**
  
  Parameters
  -------------
  mat: scipy.sparse.coo_matrix or numpy.array, 2-dimensional
      Interactions matrix, which, if provided, will be used instead of ``users``, ``items``, and
      ``ratings`` arguments
  users: Iterable[int], 1-d
      Array of user IDs, starting at 0
  items: Iterable[int], 1-d
      Array of corresponding item IDs to ``users``, starting at 0
  ratings: Iterable[int], 1-d
      Array of corresponding ratings to both ``users`` and ``items``. If ``None``, will default to
      each user in ``user`` interacting with an item with a rating value of 1
  num_negative_samples: int
      Number of negative samples to return with each ``__getitem__`` call
  allow_missing_ids: bool
      If ``False``, will check that both ``users`` and ``items`` contain each integer from 0 to
      the maximum value in the array. This check only applies when initializing an
      ``Interactions`` instance using 1-dimensional arrays ``users`` and ``items``
  remove_duplicate_user_item_pairs: bool
      Will check for and remove any duplicate user, item ID pairs from the ``Interactions`` matrix
      during initialization. Note that this will create a second sparse matrix held in memory
      to efficiently check, which could cause memory concerns for larger data. If you are sure
      that there are no duplicated, user, item ID pairs, set to ``False``
  num_users: int
      Number of users in the dataset. If ``num_users == 'infer'``, this will be set to the
      ``mat.shape[0]`` or ``max(users) + 1``, depending on the input
  num_items: int
      Number of items in the dataset. If ``num_items == 'infer'``, this will be set to the
      ``mat.shape[1]`` or ``max(items) + 1``, depending on the input
  check_num_negative_samples_is_valid: bool
      Check that ``num_negative_samples`` is less than the maximum number of items a user has
      interacted with. If it is not, then for all users who have fewer than
      ``num_negative_samples`` items not interacted with, a random sample including positive items
      will be returned as negative
  max_number_of_samples_to_consider: int
      Number of samples to try for a given user before returning an approximate negative sample.
      This should be greater than ``num_negative_samples``. If set to ``0``, approximate negative
      sampling will be used by default in ``__getitem__`` and a positive item lookup dictionary
      will NOT be built
  seed: int
      Seed for random sampling
class_docstr_tok: ["PyTorch","``","Dataset","``","for","implicit","user-item","interactions","data",".","If","``","mat","``","is","provided",",","the","``","Interactions","``","instance","will","act","as","a","wrapper","for","a","sparse","matrix","in","COOrdinate","format",",","typically","looking","like",":","*","Users","comprising","the","rows","*","Items","comprising","the","columns","*","Ratings","given","by","that","user","for","that","item","comprising","the","elements","of","the","matrix","``","Interactions","``","can","be","instantiated","instead","by","passing","in","single","arrays","with","corresponding","user_ids",",","item_ids",",","and","ratings","(","by","default",",","set","to","1","for","implicit","recommenders",")","values","with","the","same","functionality","as","a","matrix",".","Note","that","with","this","approach",",","the","number","of","users","and","items","will","be","the","maximum","values","in","those","two","columns",",","respectively",",","and","it","is","expected","that","all","integers","between","0","and","the","maximum","ID","should","appear","somewhere","in","the","data",".","By","default",",","exact","negative","sampling","will","be","used","during","each","``","__getitem__","``","call",".","To","use","approximate","negative","sampling",",","set","``","max_number_of_samples_to_consider","=","0","``",".","This","will","avoid","building","a","positive","item","lookup","dictionary","during","initialization",".","Unlike","in","``","ExplicitInteractions","``",",","we","rely","on","negative","sampling","for","implicit","data",".","Each","``","__getitem__","``","call","will","thus","return","a","nested","tuple","containing","user","IDs",",","item","IDs",",","and","sampled","negative","item","IDs",".","This","nested","vs.","non-nested","structure","is","key","for","the","model","to","determine","where","it","should","be","implicit","or","explicit",".","Use","the","table","below","for","reference",":","..","list-table",":",":",":","header-rows",":","1","*","-","``","__getitem__","``","Format","-","Expected","Meaning","-","Model","Type","*","-","``","(","(","X",",","Y",")",",","Z",")","``","-","``","(","(","user","IDs",",","item","IDs",")",",","negative","item","IDs",")","``","-","*","*","Implicit","*","*","*","-","``","(","X",",","Y",",","Z",")","``","-","``","(","user","IDs",",","item","IDs",",","ratings",")","``","-","*","*","Explicit","*","*","Parameters","--","--","--","--","--","--","-","mat",":","scipy.sparse.coo_matrix","or","numpy.array",",","2-dimensional","Interactions","matrix",",","which",",","if","provided",",","will","be","used","instead","of","``","users","``",",","``","items","``",",","and","``","ratings","``","arguments","users",":","Iterable","[","int","]",",","1-d","Array","of","user","IDs",",","starting","at","0","items",":","Iterable","[","int","]",",","1-d","Array","of","corresponding","item","IDs","to","``","users","``",",","starting","at","0","ratings",":","Iterable","[","int","]",",","1-d","Array","of","corresponding","ratings","to","both","``","users","``","and","``","items","``",".","If","``","None","``",",","will","default","to","each","user","in","``","user","``","interacting","with","an","item","with","a","rating","value","of","1","num_negative_samples",":","int","Number","of","negative","samples","to","return","with","each","``","__getitem__","``","call","allow_missing_ids",":","bool","If","``","False","``",",","will","check","that","both","``","users","``","and","``","items","``","contain","each","integer","from","0","to","the","maximum","value","in","the","array",".","This","check","only","applies","when","initializing","an","``","Interactions","``","instance","using","1-dimensional","arrays","``","users","``","and","``","items","``","remove_duplicate_user_item_pairs",":","bool","Will","check","for","and","remove","any","duplicate","user",",","item","ID","pairs","from","the","``","Interactions","``","matrix","during","initialization",".","Note","that","this","will","create","a","second","sparse","matrix","held","in","memory","to","efficiently","check",",","which","could","cause","memory","concerns","for","larger","data",".","If","you","are","sure","that","there","are","no","duplicated",",","user",",","item","ID","pairs",",","set","to","``","False","``","num_users",":","int","Number","of","users","in","the","dataset",".","If","``","num_users","==","'infer","'","``",",","this","will","be","set","to","the","``","mat.shape","[","0","]","``","or","``","max","(","users",")","+","1","``",",","depending","on","the","input","num_items",":","int","Number","of","items","in","the","dataset",".","If","``","num_items","==","'infer","'","``",",","this","will","be","set","to","the","``","mat.shape","[","1","]","``","or","``","max","(","items",")","+","1","``",",","depending","on","the","input","check_num_negative_samples_is_valid",":","bool","Check","that","``","num_negative_samples","``","is","less","than","the","maximum","number","of","items","a","user","has","interacted","with",".","If","it","is","not",",","then","for","all","users","who","have","fewer","than","``","num_negative_samples","``","items","not","interacted","with",",","a","random","sample","including","positive","items","will","be","returned","as","negative","max_number_of_samples_to_consider",":","int","Number","of","samples","to","try","for","a","given","user","before","returning","an","approximate","negative","sample",".","This","should","be","greater","than","``","num_negative_samples","``",".","If","set","to","``","0","``",",","approximate","negative","sampling","will","be","used","by","default","in","``","__getitem__","``","and","a","positive","item","lookup","dictionary","will","NOT","be","built","seed",":","int","Seed","for","random","sampling"]
docstr: Build positive item dictionary lookup for exact negative sampling.
docstr_tok: ["Build","positive","item","dictionary","lookup","for","exact","negative","sampling","."]
code: def _generate_positive_item_set(self) -> None:
      """Build positive item dictionary lookup for exact negative sampling."""
      self.positive_items = set(zip(self.mat.row, self.mat.col))
  
imports: from abc import ABCMeta, abstractmethod
  import collections
  import random
  import textwrap
  from typing import Any, Iterable, List, Optional, Tuple, Union
  import warnings
  import numpy
  import pandas
  from scipy.sparse import coo_matrix, dok_matrix
  import torch
  from tqdm.auto import tqdm
  import collie
label_desc: Use image node_id 2 for calling the Interactions obj's underlying member method code with example usage: obj._generate_positive_item_set() without return types