class_docstr: Task for training masked language models (e.g., BERT, RoBERTa).
class_docstr_tok: ["Task","for","training","masked","language","models","(","e.g.",",","BERT",",","RoBERTa",")","."]
code: def _get_whole_word_mask(self):
      # create masked input and targets
      if self.args.mask_whole_words:
          bpe = encoders.build_bpe(self.args)
          if bpe is not None:
  
              def is_beginning_of_word(i):
                  if i < self.source_dictionary.nspecial:
                      # special elements are always considered beginnings
                      return True
                  tok = self.source_dictionary[i]
                  if tok.startswith("madeupword"):
                      return True
                  try:
                      return bpe.is_beginning_of_word(tok)
                  except ValueError:
                      return True
  
              mask_whole_words = torch.ByteTensor(
                  list(
                      map(
                          is_beginning_of_word,
                          range(len(self.source_dictionary)),
                      )
                  )
              )
      else:
          mask_whole_words = None
      return mask_whole_words
  
file_path: fairseq/fairseq/tasks/multilingual_masked_lm.py
imports: import logging
  import os
  import numpy
  import torch
  from fairseq import utils
  from fairseq.data import ConcatDataset, Dictionary, IdDataset, MaskTokensDataset, NestedDictionaryDataset, NumelDataset, NumSamplesDataset, PadDataset, PrependTokenDataset, RawLabelDataset, ResamplingDataset, SortDataset, TokenBlockDataset, data_utils, encoders
  from fairseq.tasks import LegacyFairseqTask, register_task
label_desc: Use image node_id 4 for calling the MultiLingualMaskedLMTask obj's underlying member method code with example usage: obj._get_whole_word_mask() and returns: mask_whole_words, True, True, bpe, True