class_docstr: DiffRec is a generative recommender model which infers users' interaction probabilities in a denoising manner.
  Note that DiffRec simultaneously ranks all items for each user.
  We implement the the DiffRec model with only user dataloader.
class_docstr_tok: ["DiffRec","is","a","generative","recommender","model","which","infers","users","'","interaction","probabilities","in","a","denoising","manner",".","Note","that","DiffRec","simultaneously","ranks","all","items","for","each","user",".","We","implement","the","the","DiffRec","model","with","only","user","dataloader","."]
docstr: Add time-aware reweighting to the original user-item interaction matrix when config['time-aware'] is True.
code: def build_histroy_items(self, dataset):
      r"""
      Add time-aware reweighting to the original user-item interaction matrix when config['time-aware'] is True.
      """
      if not self.time_aware:
          super().build_histroy_items(dataset)
      else:
          inter_feat = copy.deepcopy(dataset.inter_feat)
          inter_feat.sort(dataset.time_field)
          user_ids, item_ids = (
              inter_feat[dataset.uid_field].numpy(),
              inter_feat[dataset.iid_field].numpy(),
          )
  
          w_max = self.w_max
          w_min = self.w_min
          values = np.zeros(len(inter_feat))
  
          row_num = dataset.user_num
          row_ids, col_ids = user_ids, item_ids
  
          for uid in range(1, row_num + 1):
              uindex = np.argwhere(user_ids == uid).flatten()
              int_num = len(uindex)
              weight = np.linspace(w_min, w_max, int_num)
              values[uindex] = weight
  
          history_len = np.zeros(row_num, dtype=np.int64)
          for row_id in row_ids:
              history_len[row_id] += 1
  
          max_inter_num = np.max(history_len)
          col_num = max_inter_num
  
          history_matrix = np.zeros((row_num, col_num), dtype=np.int64)
          history_value = np.zeros((row_num, col_num))
          history_len[:] = 0
  
          for row_id, value, col_id in zip(row_ids, values, col_ids):
              if history_len[row_id] >= col_num:
                  continue
              history_matrix[row_id, history_len[row_id]] = col_id
              history_value[row_id, history_len[row_id]] = value
              history_len[row_id] += 1
  
          self.history_item_id = torch.LongTensor(history_matrix)
          self.history_item_value = torch.FloatTensor(history_value)
          self.history_item_id = self.history_item_id.to(self.device)
          self.history_item_value = self.history_item_value.to(
              self.device
          )
  
imports: import enum
  import math
  import copy
  import numpy
  import torch
  import torch.nn.functional
  import torch.nn
  from recbole.model.init import xavier_normal_initialization
  from recbole.utils.enum_type import InputType
  from recbole.model.abstract_recommender import AutoEncoderMixin, GeneralRecommender
  from recbole.model.layers import MLPLayers
  import typing
label_desc: Use image node_id 2 for calling the DiffRec obj's underlying member method code with example usage: obj.build_histroy_items(dataset) without return types