class_docstr: Compute Bert embeddings, from a text dataset.
class_docstr_tok: ["Compute","Bert","embeddings",",","from","a","text","dataset","."]
code: def __init__(self, batch_size, max_bert_seq_length, embedder_type):
      args = get_args()
  
      assert args.output_bert_embeddings
  
      (
          self.models,
          optimizer,
          opt_param_scheduler,
      ) = setup_model_and_optimizer(
          model_provider, ModelType.encoder_or_decoder
      )
      self.batch_size = batch_size
      self.max_bert_seq_length = max_bert_seq_length
  
      # Init Huggingface, if in use.
      if embedder_type == "megatron":
          self.huggingface_embedder = None
      elif embedder_type == "huggingface":
          self.huggingface_embedder = HuggingfaceEmbedder(
              batch_size, max_bert_seq_length
          )
      else:
          raise Exception(
              "specialize for embedder type '%s'." % embedder_type
          )
  
imports: from functools import partial
  import numpy
  import os
  import time
  import torch
  from torch.utils.data import BatchSampler, DataLoader, SequentialSampler, Subset
  from torch.utils.data._utils.collate import default_collate
  from tqdm import tqdm
  from megatron import get_args, get_tokenizer, print_rank_0
  from megatron import core
  from megatron.arguments import core_transformer_config_from_args
  from megatron.core.enums import ModelType
  from megatron.core.pipeline_parallel import get_forward_backward_func
  from megatron.model import BertModel
  from megatron.training import setup_model_and_optimizer
  from .dataset import BertEmbeddingDataset
  from .external_libs import h5py
  from .huggingface import HuggingfaceEmbedder
  from .utils import get_missing_blocks_by_rank
label_desc: Use image node_id 1 to create a new BertEmbedder object  with example: obj = BertEmbedder(batch_size, max_bert_seq_length, embedder_type)