class_docstr: Masked language model for BERT style pre-training.
class_docstr_tok: ["Masked","language","model","for","BERT","style","pre-training","."]
code: def _select_tokens_to_mask(
      self, tokens: torch.Tensor, mask_prob: float
  ) -> torch.tensor:
      if self.masking_strategy == MaskingStrategy.RANDOM:
          mask = random_masking(tokens, mask_prob)
          if not self.mask_bos:
              bos_idx = self.vocab.idx[self.token_tensorizer.bos_token]
              mask *= (tokens != bos_idx).long()
          return mask
      elif self.masking_strategy == MaskingStrategy.FREQUENCY:
          return frequency_based_masking(
              tokens, self.token_sampling_weights, mask_prob
          )
      else:
          raise NotImplementedError(
              "Specified Masking Strategy isnt currently implemented."
          )
  
imports: from typing import Dict, List
  import torch
  from fairseq.modules.transformer_sentence_encoder import init_bert_params
  from pytext.common.constants import SpecialTokens, Stage
  from pytext.config import ConfigBase
  from pytext.data.bert_tensorizer import BERTTensorizerBase
  from pytext.data.tensorizers import Tensorizer
  from pytext.data.utils import Vocabulary
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.masking_utils import frequency_based_masking, MaskingStrategy, random_masking
  from pytext.models.model import BaseModel
  from pytext.models.module import create_module
  from pytext.models.output_layers.lm_output_layer import LMOutputLayer
  from pytext.models.representations.transformer_sentence_encoder import TransformerSentenceEncoder
  from pytext.models.representations.transformer_sentence_encoder_base import TransformerSentenceEncoderBase
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 6 for calling the MaskedLanguageModel obj's underlying member method code with example usage: obj._select_tokens_to_mask(tokens, mask_prob) and returns: mask, frequency_based_masking