class_docstr: Bert4Rec data pre-processer to get the masked sequences for each user
  
  Args:
      raw_data (pd.DataFrame): the raw dataframe
      min_rating (int): minimum valid rating
      min_uc (int): minimum user ratings count
      min_sc (int): minimum item count for each valid use
      name (str): dataset for experiment, current support ml-1m, ml-20m, random
      max_len (int): max length of the Bert embedding dimensio
      mask_prob (float): probability of the mask
      dupe_factor (int): number of duplication while generating the random masked seqs
  
  Returns:
      Dict[str, Any]
  
  Example::
  
      raw_data = get_raw_dataframe(
          "random", 5, 40, 200, 4, None
      )
      df = Bert4RecPreprocsser(
          raw_data,
          4,
          5,
          0,
          "random",
          4,
          0.2,
          1,
      ).get_processed_dataframes()
class_docstr_tok: ["Bert4Rec","data","pre-processer","to","get","the","masked","sequences","for","each","user","Args",":","raw_data","(","pd.DataFrame",")",":","the","raw","dataframe","min_rating","(","int",")",":","minimum","valid","rating","min_uc","(","int",")",":","minimum","user","ratings","count","min_sc","(","int",")",":","minimum","item","count","for","each","valid","use","name","(","str",")",":","dataset","for","experiment",",","current","support","ml-1m",",","ml-20m",",","random","max_len","(","int",")",":","max","length","of","the","Bert","embedding","dimensio","mask_prob","(","float",")",":","probability","of","the","mask","dupe_factor","(","int",")",":","number","of","duplication","while","generating","the","random","masked","seqs","Returns",":","Dict","[","str",",","Any","]","Example",":",":","raw_data","=","get_raw_dataframe","(","``","random","''",",","5",",","40",",","200",",","4",",","None",")","df","=","Bert4RecPreprocsser","(","raw_data",",","4",",","5",",","0",",","``","random","''",",","4",",","0.2",",","1",",",")",".get_processed_dataframes","(",")"]
code: def _generate_masked_train_set(
      self,
      train: Dict[int, List[int]],
      dupe_factor: int,
      need_padding: bool = True,
  ) -> pd.DataFrame:
      df = []
      for user, seq in train.items():
          sliding_step = (int)(0.1 * self.max_len)
          beg_idx = list(
              range(
                  len(seq) - self.max_len,
                  0,
                  -sliding_step if sliding_step != 0 else -1,
              )
          )
          beg_idx.append(0)
          seqs = [seq[i : i + self.max_len] for i in beg_idx[::-1]]
          for seq in seqs:
              for _ in range(dupe_factor):
                  tokens = []
                  labels = []
                  for s in seq:
                      prob = random.random()
                      if prob < self.mask_prob:
                          prob /= self.mask_prob
  
                          if prob < 0.8:
                              tokens.append(self.mask_token)
                          else:
                              tokens.append(
                                  random.randint(1, self.item_count)
                              )
                          labels.append(s)
                      else:
                          tokens.append(s)
                          labels.append(0)
                  if need_padding:
                      mask_len = self.max_len - len(tokens)
                      tokens = [0] * mask_len + tokens
                      labels = [0] * mask_len + labels
                  df.append([user, tokens, labels])
      return pd.DataFrame(df, columns=["user", "seqs", "labels"])
  
imports: import random
  from collections import Counter
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling the Bert4RecPreprocsser obj's underlying member method code with example usage: obj._generate_masked_train_set(train, dupe_factor, need_padding) and returns: pd