class_docstr: Module to load BERT pre-trained weights.
  Based on:
  LXMERT
  https://github.com/airsplay/lxmert
  BERT (pytorch-transformer)
  https://github.com/huggingface/transformers
code: def from_pretrained(
      cls,
      num_language_layers,
      num_vision_layers,
      num_mixed_layers,
      bert_config,
      state_dict=None,
      cache_dir=None,
      from_tf=False,
      path_or_repo_id="bert-base-uncased",
      filename="pytorch_model.bin",
      *inputs,
      **kwargs,
  ):
      weights_path = cached_file(
          path_or_repo_id, filename, cache_dir=cache_dir
      )
      model = cls(
          num_language_layers,
          num_vision_layers,
          num_mixed_layers,
          bert_config,
          *inputs,
          **kwargs,
      )
      if state_dict is None and not from_tf:
          state_dict = torch.load(
              weights_path,
              map_location="cpu"
              if not torch.cuda.is_available()
              else None,
          )
      if from_tf:
          return load_tf_weights_in_bert(model, weights_path)
      old_keys = []
      new_keys = []
      for key in state_dict.keys():
          new_key = None
          if "gamma" in key:
              new_key = key.replace("gamma", "weight")
          if "beta" in key:
              new_key = key.replace("beta", "bias")
          if new_key:
              old_keys.append(key)
              new_keys.append(new_key)
      for old_key, new_key in zip(old_keys, new_keys):
          state_dict[new_key] = state_dict.pop(old_key)
      missing_keys: list = []
      unexpected_keys: list = []
      error_msgs: list = []
      metadata = getattr(state_dict, "_metadata", None)
      state_dict = state_dict.copy()
      if metadata is not None:
          state_dict._metadata = metadata
  
      def load(module, prefix=""):
          local_metadata = (
              {} if metadata is None else metadata.get(prefix[:-1], {})
          )
          module._load_from_state_dict(
              state_dict,
              prefix,
              local_metadata,
              True,
              missing_keys,
              unexpected_keys,
              error_msgs,
          )
          for name, child in module._modules.items():
              if child is not None:
                  load(child, prefix + name + ".")
  
      start_prefix = ""
      if not hasattr(model, "bert") and any(
          s.startswith("bert.") for s in state_dict.keys()
      ):
          start_prefix = "bert."
      load(model, prefix=start_prefix)
      return model
  
imports: from __future__ import annotations
  import math
  from collections.abc import Sequence
  import torch
  from torch import nn
  from monai.config.type_definitions import PathLike
  from monai.utils import optional_import
label_desc: Use image node_id 3 for calling the BertPreTrainedModel obj's underlying member method code with example usage: obj.from_pretrained(cls, num_language_layers, num_vision_layers, num_mixed_layers, bert_config, state_dict, cache_dir, from_tf, path_or_repo_id, filename) and returns: model, load_tf_weights_in_bert