class_docstr: Mask item sequence for training.
class_docstr_tok: ["Mask","item","sequence","for","training","."]
code: def _append_mask_last(self, interaction, n_items, device):
      batch_size = interaction[self.ITEM_SEQ].size(0)
      pos_items, neg_items, masked_index, masked_item_sequence = (
          [],
          [],
          [],
          [],
      )
      seq_instance = interaction[self.ITEM_SEQ].cpu().numpy().tolist()
      item_seq_len = (
          interaction[self.ITEM_SEQ_LEN].cpu().numpy().tolist()
      )
      for instance, lens in zip(seq_instance, item_seq_len):
          mask_seq = instance.copy()
          ext = instance[lens - 1]
          mask_seq[lens - 1] = n_items
          masked_item_sequence.append(mask_seq)
          pos_items.append(
              self._padding_sequence([ext], self.mask_item_length)
          )
          neg_items.append(
              self._padding_sequence(
                  [self._neg_sample(instance, n_items)],
                  self.mask_item_length,
              )
          )
          masked_index.append(
              self._padding_sequence([lens - 1], self.mask_item_length)
          )
      # [B Len]
      masked_item_sequence = torch.tensor(
          masked_item_sequence, dtype=torch.long, device=device
      ).view(batch_size, -1)
      # [B mask_len]
      pos_items = torch.tensor(
          pos_items, dtype=torch.long, device=device
      ).view(batch_size, -1)
      # [B mask_len]
      neg_items = torch.tensor(
          neg_items, dtype=torch.long, device=device
      ).view(batch_size, -1)
      # [B mask_len]
      masked_index = torch.tensor(
          masked_index, dtype=torch.long, device=device
      ).view(batch_size, -1)
      new_dict = {
          self.MASK_ITEM_SEQ: masked_item_sequence,
          self.POS_ITEMS: pos_items,
          self.NEG_ITEMS: neg_items,
          self.MASK_INDEX: masked_index,
      }
      ft_interaction = deepcopy(interaction)
      ft_interaction.update(Interaction(new_dict))
      return ft_interaction
  
imports: import math
  import numpy
  import random
  import torch
  from copy import deepcopy
  from recbole.data.interaction import Interaction, cat_interactions
label_desc: Use image node_id 4 for calling the MaskItemSequence obj's underlying member method code with example usage: obj._append_mask_last(interaction, n_items, device) and returns: ft_interaction