docstr: For memory, we only need calculate loss for masked position.
  Generate a multi-hot vector to indicate the masked position for masked sequence, and then is used for
  gathering the masked position hidden representation.
  
  Examples:
      sequence: [1 2 3 4 5]
  
      masked_sequence: [1 mask 3 mask 5]
  
      masked_index: [1, 3]
  
      max_length: 5
  
      multi_hot_embed: [[0 1 0 0 0], [0 0 0 1 0]]
docstr_tok: ["For","memory",",","we","only","need","calculate","loss","for","masked","position",".","Generate","a","multi-hot","vector","to","indicate","the","masked","position","for","masked","sequence",",","and","then","is","used","for","gathering","the","masked","position","hidden","representation",".","Examples",":","sequence",":","[","1","2","3","4","5","]","masked_sequence",":","[","1","mask","3","mask","5","]","masked_index",":","[","1",",","3","]","max_length",":","5","multi_hot_embed",":","[","[","0","1","0","0","0","]",",","[","0","0","0","1","0","]","]"]
code: def multi_hot_embed(self, masked_index, max_length):
      """
      For memory, we only need calculate loss for masked position.
      Generate a multi-hot vector to indicate the masked position for masked sequence, and then is used for
      gathering the masked position hidden representation.
  
      Examples:
          sequence: [1 2 3 4 5]
  
          masked_sequence: [1 mask 3 mask 5]
  
          masked_index: [1, 3]
  
          max_length: 5
  
          multi_hot_embed: [[0 1 0 0 0], [0 0 0 1 0]]
      """
      masked_index = masked_index.view(-1)
      multi_hot = torch.zeros(
          masked_index.size(0), max_length, device=masked_index.device
      )
      multi_hot[torch.arange(masked_index.size(0)), masked_index] = 1
      return multi_hot
  
file_path: RecBole/recbole/model/sequential_recommender/bert4rec.py
imports: import random
  import torch
  from torch import nn
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.layers import TransformerEncoder
label_desc: Use image node_id 5 for calling the BERT4Rec obj's underlying member method code with example usage: obj.multi_hot_embed(masked_index, max_length) and returns: multi_hot