code: def __init__(
      self,
      raw_data,
      total_users,
      total_items,
      implicit_negative=True,
      num_negatives=None,
      name="dataset",
      seed=100,
      sortby=None,
      asc=True,
  ):
      random.seed(seed)
      self.name = name
      if type(raw_data) == np.ndarray:
          self._raw_data = raw_data
      else:
          raise TypeError(
              "Unsupported data input schema. Please use structured numpy array."
          )
      self._rand_ids = []
  
      self._total_users = total_users
      self._total_items = total_items
  
      self._sortby = sortby
  
      self._index_store = dict()
      if implicit_negative:
          self._index_store["positive"] = dict()
          for ind, entry in enumerate(self._raw_data):
              if entry["user_id"] not in self._index_store["positive"]:
                  self._index_store["positive"][
                      entry["user_id"]
                  ] = dict()
              self._index_store["positive"][entry["user_id"]][
                  entry["item_id"]
              ] = ind
          self._index_store["positive_sets"] = dict()
          for user_id in self._index_store["positive"]:
              self._index_store["positive_sets"][user_id] = set(
                  self._index_store["positive"][user_id]
              )
          if num_negatives is not None:
              self._index_store["negative"] = dict()
              for user_id in self._index_store["positive"]:
                  self._index_store["negative"][user_id] = dict()
                  shuffled_items = np.random.permutation(
                      self._total_items
                  )
                  for item in shuffled_items:
                      if (
                          item
                          not in self._index_store["positive"][user_id]
                      ):
                          self._index_store["negative"][user_id][
                              item
                          ] = None
                      if (
                          len(self._index_store["negative"][user_id])
                          == num_negatives
                      ):
                          break
              self._index_store["negative_sets"] = dict()
              for user_id in self._index_store["negative"]:
                  self._index_store["negative_sets"][user_id] = set(
                      self._index_store["negative"][user_id]
                  )
      else:
          self._index_store["positive"] = dict()
          self._index_store["negative"] = dict()
          for ind, entry in enumerate(self._raw_data):
              if entry["label"] > 0:
                  if (
                      entry["user_id"]
                      not in self._index_store["positive"]
                  ):
                      self._index_store["positive"][
                          entry["user_id"]
                      ] = dict()
                  self._index_store["positive"][entry["user_id"]][
                      entry["item_id"]
                  ] = ind
              else:
                  if (
                      entry["user_id"]
                      not in self._index_store["negative"]
                  ):
                      self._index_store["negative"][
                          entry["user_id"]
                      ] = dict()
                  self._index_store["negative"][entry["user_id"]][
                      entry["item_id"]
                  ] = ind
          self._index_store["positive_sets"] = dict()
          for user_id in self._index_store["positive"]:
              self._index_store["positive_sets"][user_id] = set(
                  self._index_store["positive"][user_id]
              )
          self._index_store["negative_sets"] = dict()
          for user_id in self._index_store["negative"]:
              self._index_store["negative_sets"][user_id] = set(
                  self._index_store["negative"][user_id]
              )
  
      if self._sortby is not None:
          self._index_store["positive_sorts"] = dict()
          for user_id in self._index_store["positive_sets"]:
              self._index_store["positive_sorts"][user_id] = sorted(
                  list(self._index_store["positive_sets"][user_id]),
                  key=lambda item: self._raw_data[
                      self._index_store["positive"][user_id][item]
                  ][self._sortby],
                  reverse=not asc,
              )
  
file_path: openrec/openrec/tf1/utils/dataset.py
imports: import numpy
  import random
label_desc: Use image node_id 1 to create a new Dataset object from inherited base classes: object with example: obj = Dataset(raw_data, total_users, total_items, implicit_negative, num_negatives, name, seed, sortby, asc)