class_docstr: Mask item sequence for training.
class_docstr_tok: ["Mask","item","sequence","for","training","."]
code: def __call__(self, dataset, interaction):
      item_seq = interaction[self.ITEM_SEQ]
      device = item_seq.device
      batch_size = item_seq.size(0)
      n_items = dataset.num(self.ITEM_ID)
      sequence_instances = item_seq.cpu().numpy().tolist()
  
      # Masked Item Prediction
      # [B * Len]
      masked_item_sequence = []
      pos_items = []
      neg_items = []
      masked_index = []
  
      if random.random() < self.ft_ratio:
          interaction = self._append_mask_last(
              interaction, n_items, device
          )
      else:
          for instance in sequence_instances:
              # WE MUST USE 'copy()' HERE!
              masked_sequence = instance.copy()
              pos_item = []
              neg_item = []
              index_ids = []
              for index_id, item in enumerate(instance):
                  # padding is 0, the sequence is end
                  if item == 0:
                      break
                  prob = random.random()
                  if prob < self.mask_ratio:
                      pos_item.append(item)
                      neg_item.append(
                          self._neg_sample(instance, n_items)
                      )
                      masked_sequence[index_id] = n_items
                      index_ids.append(index_id)
  
              masked_item_sequence.append(masked_sequence)
              pos_items.append(
                  self._padding_sequence(
                      pos_item, self.mask_item_length
                  )
              )
              neg_items.append(
                  self._padding_sequence(
                      neg_item, self.mask_item_length
                  )
              )
              masked_index.append(
                  self._padding_sequence(
                      index_ids, 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,
          }
          interaction.update(Interaction(new_dict))
      return 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 5 for calling the MaskItemSequence obj's underlying member method code with example usage: obj.__call__(dataset, interaction) and returns: interaction