class_docstr: Base class for NLP Models.
      
class_docstr_tok: ["Base","class","for","NLP","Models","."]
docstr: Adds encoder config to .nemo archive for Jarvis.
          
docstr_tok: ["Adds","encoder","config","to",".nemo","archive","for","Jarvis","."]
code: def register_bert_model(self):
      """Adds encoder config to .nemo archive for Jarvis."""
      # check if there is an encoder, warn if not
      if self.bert_model is not None:
          # get encoder config and create source for artifact
          if isinstance(self.bert_model, BertModule):
              # HuggingFace Transformer Config
              pretrained_model_name = self.bert_model.name_or_path
              # Some HF names have "/" in them so we replace with _
              pretrained_model_name = pretrained_model_name.replace(
                  "/", "_"
              )
              encoder_config_path = (
                  pretrained_model_name + "_encoder_config"
              )
              encoder_config_src = os.path.join(
                  NEMO_NLP_TMP, encoder_config_path + ".json"
              )
              self.bert_model.config.to_json_file(
                  encoder_config_src
              )  # name requested by jarvis team
              self.register_artifact(
                  "language_model.config_file", encoder_config_src
              )  # for .nemo
          # MegatronBertModel's superclass is NLP model, hence can't check for isinstance of self.bert_modelel
          elif (
              hasattr(self, "pretrained_model_name")
              and "megatron" in self.pretrained_model_name
          ):
              if self.pretrained_model_name in MEGATRON_CONFIG_MAP:
                  output_config = MEGATRON_CONFIG_MAP[
                      self.pretrained_model_name
                  ]["config"]
                  if output_config is not None:
                      encoder_config_path = (
                          self.pretrained_model_name + "_encoder_config"
                      )
                      encoder_config_src = os.path.join(
                          NEMO_NLP_TMP, encoder_config_path + ".json"
                      )
                      with open(
                          encoder_config_src, "w", encoding="utf-8"
                      ) as f:
                          f.write(
                              json.dumps(
                                  output_config,
                                  indent=2,
                                  sort_keys=True,
                              )
                              + "\n"
                          )
                      self.register_artifact(
                          "language_model.config_file",
                          encoder_config_src,
                      )  # for .nemo
                  else:
                      # No defaults as this case can be any possible hyper-parameter combination of MegatronBert config
                      logging.info(
                          f"For {self.pretrained_model_name}, set the config_file in the YAML file"
                      )
              else:
                  logging.info(
                      f"Registering MegatronBERT model config for {self.pretrained_model_name} is not yet supported. \
                          Please override this method if needed."
                  )
          else:
              logging.info(
                  f"Registering BERT model config for {self.bert_model} is not yet supported. Please override this method if needed."
              )
  
imports: import copy
  import hashlib
  import json
  import os
  from typing import Any, Mapping, Optional, Union
  import torch
  from lightning_fabric.utilities.cloud_io import _load
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from pytorch_lightning.core.saving import _load_state
  from pytorch_lightning.core.saving import load_hparams_from_tags_csv, load_hparams_from_yaml
  from pytorch_lightning.utilities import rank_zero_only
  from pytorch_lightning.utilities.migration import pl_legacy_patch
  from transformers import TRANSFORMERS_CACHE
  from nemo.collections.common.tokenizers.huggingface.auto_tokenizer import AutoTokenizer
  from nemo.collections.nlp.modules import BertModule
  from nemo.collections.nlp.modules.common.huggingface.huggingface_utils import VOCAB_FILE_NAME
  from nemo.collections.nlp.modules.common.lm_utils import get_lm_model
  from nemo.collections.nlp.modules.common.megatron.megatron_utils import MEGATRON_CONFIG_MAP, get_megatron_pretrained_bert_models
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.collections.nlp.parts.nlp_overrides import NLPSaveRestoreConnector
  from nemo.core.classes import ModelPT
  from nemo.core.classes.exportable import Exportable
  from nemo.core.connectors.save_restore_connector import SaveRestoreConnector
  from nemo.utils import AppState, logging
label_desc: Use image node_id 3 for calling the NLPModel obj's underlying member method code with example usage: obj.register_bert_model() without return types