class_docstr: BERT masked LM using Huggingface Transformers and TensorFlow 2.
class_docstr_tok: ["BERT","masked","LM","using","Huggingface","Transformers","and","TensorFlow","2","."]
code: def __init__(self, model_name_or_path="bert-base-uncased", top_k=10):
      super().__init__()
  
      # Normally path is a directory; if it's an archive file, download and
      # extract to the transformers cache.
      if model_name_or_path.endswith(".tar.gz"):
          model_name_or_path = file_cache.cached_path(
              model_name_or_path, extract_compressed_file=True
          )
  
      self.tokenizer = transformers.AutoTokenizer.from_pretrained(
          model_name_or_path, use_fast=False
      )
      # TODO(lit-dev): switch to TFBertForPreTraining to get the next-sentence
      # prediction head as well.
      self.model = model_utils.load_pretrained(
          transformers.TFBertForMaskedLM,
          model_name_or_path,
          output_hidden_states=True,
          output_attentions=True,
      )
      self.top_k = top_k
  
imports: import re
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.examples.models import model_utils
  from lit_nlp.lib import file_cache
  from lit_nlp.lib import utils
  import numpy
  import tensorflow
  import transformers
label_desc: Use image node_id 3 to create a new BertMLM object from inherited base classes: lit_model with example: obj = BertMLM(model_name_or_path, top_k)