class_docstr: :class:`SequentialDataset` is based on :class:`~recbole.data.dataset.dataset.Dataset`,
  and provides augmentation interface to adapt to Sequential Recommendation,
  which can accelerate the data loader.
  
  Attributes:
      max_item_list_len (int): Max length of historical item list.
      item_list_length_field (str): Field name for item lists' length.
docstr: Augmentation processing for sequential dataset.
  
  E.g., ``u1`` has purchase sequence ``<i1, i2, i3, i4>``,
  then after augmentation, we will generate three cases.
  
  ``u1, <i1> | i2``
  
  (Which means given user_id ``u1`` and item_seq ``<i1>``,
  we need to predict the next item ``i2``.)
  
  The other cases are below:
  
  ``u1, <i1, i2> | i3``
  
  ``u1, <i1, i2, i3> | i4``
docstr_tok: ["Augmentation","processing","for","sequential","dataset",".","E.g.",",","``","u1","``","has","purchase","sequence","``","<","i1",",","i2",",","i3",",","i4",">","``",",","then","after","augmentation",",","we","will","generate","three","cases",".","``","u1",",","<","i1",">","|","i2","``","(","Which","means","given","user_id","``","u1","``","and","item_seq","``","<","i1",">","``",",","we","need","to","predict","the","next","item","``","i2","``",".",")","The","other","cases","are","below",":","``","u1",",","<","i1",",","i2",">","|","i3","``","``","u1",",","<","i1",",","i2",",","i3",">","|","i4","``"]
code: def data_augmentation(self):
      """Augmentation processing for sequential dataset.
  
      E.g., ``u1`` has purchase sequence ``<i1, i2, i3, i4>``,
      then after augmentation, we will generate three cases.
  
      ``u1, <i1> | i2``
  
      (Which means given user_id ``u1`` and item_seq ``<i1>``,
      we need to predict the next item ``i2``.)
  
      The other cases are below:
  
      ``u1, <i1, i2> | i3``
  
      ``u1, <i1, i2, i3> | i4``
      """
      self.logger.debug("data_augmentation")
  
      self._aug_presets()
  
      self._check_field("uid_field", "time_field")
      max_item_list_len = self.config["MAX_ITEM_LIST_LENGTH"]
      self.sort(by=[self.uid_field, self.time_field], ascending=True)
      last_uid = None
      uid_list, item_list_index, target_index, item_list_length = (
          [],
          [],
          [],
          [],
      )
      seq_start = 0
      for i, uid in enumerate(self.inter_feat[self.uid_field].numpy()):
          if last_uid != uid:
              last_uid = uid
              seq_start = i
          else:
              if i - seq_start > max_item_list_len:
                  seq_start += 1
              uid_list.append(uid)
              item_list_index.append(slice(seq_start, i))
              target_index.append(i)
              item_list_length.append(i - seq_start)
  
      uid_list = np.array(uid_list)
      item_list_index = np.array(item_list_index)
      target_index = np.array(target_index)
      item_list_length = np.array(item_list_length, dtype=np.int64)
  
      new_length = len(item_list_index)
      new_data = self.inter_feat[target_index]
      new_dict = {
          self.item_list_length_field: torch.tensor(item_list_length),
      }
  
      for field in self.inter_feat:
          if field != self.uid_field:
              list_field = getattr(self, f"{field}_list_field")
              list_len = self.field2seqlen[list_field]
              shape = (
                  (new_length, list_len)
                  if isinstance(list_len, int)
                  else (new_length,) + list_len
              )
              if (
                  self.field2type[field]
                  in [FeatureType.FLOAT, FeatureType.FLOAT_SEQ]
                  and field in self.config["numerical_features"]
              ):
                  shape += (2,)
              new_dict[list_field] = torch.zeros(
                  shape, dtype=self.inter_feat[field].dtype
              )
  
              value = self.inter_feat[field]
              for i, (index, length) in enumerate(
                  zip(item_list_index, item_list_length)
              ):
                  new_dict[list_field][i][:length] = value[index]
  
      new_data.update(Interaction(new_dict))
      self.inter_feat = new_data
  
file_path: RecBole/recbole/data/dataset/sequential_dataset.py
imports: import numpy
  import torch
  from recbole.data.dataset import Dataset
  from recbole.data.interaction import Interaction
  from recbole.utils.enum_type import FeatureType, FeatureSource
label_desc: Use image node_id 4 for calling the SequentialDataset obj's underlying member method code with example usage: obj.data_augmentation() without return types