code: def parse_weights(
      weight_dict: OrderedDict,
      parent_key: str,
      total: list,
      converted: OrderedDict,
      translator: dict,
  ):
      for key in weight_dict:
          new_key = key
          name_translate = translator
  
          for replace_key in name_translate:
              if key.find(replace_key) >= 0:
                  new_key = key.replace(
                      replace_key, name_translate[replace_key]
                  )
          if isinstance(weight_dict[key], OrderedDict) or isinstance(
              weight_dict[key], dict
          ):
              parse_weights(
                  weight_dict[key],
                  parent_key + "." + new_key,
                  total,
                  converted,
                  translator,
              )
          else:
              num_parameters = torch.prod(
                  torch.tensor(weight_dict[key].cpu().size())
              ).item()
              total[0] += num_parameters
              final_key = "model" + parent_key + "." + new_key
              converted[final_key] = weight_dict[key]
  
imports: import importlib
  import os
  import pathlib
  import sys
  from argparse import ArgumentParser
  from collections import OrderedDict
  from typing import Any, Optional
  import torch
  from lightning_fabric.utilities.cloud_io import _load
  from megatron.core import parallel_state
  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.trainer.trainer import Trainer
  from pytorch_lightning.utilities.migration import pl_legacy_patch
  from nemo.collections.nlp.models.language_modeling.megatron_bert_model import MegatronBertModel
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_model import MegatronGPTModel
  from nemo.collections.nlp.modules.common.megatron.megatron_init import initialize_model_parallel_for_nemo
  from nemo.collections.nlp.parts.nlp_overrides import NLPSaveRestoreConnector
  from nemo.utils import AppState, logging
  from nemo.utils.distributed import initialize_distributed
  from nemo.utils.model_utils import inject_model_parallel_rank, uninject_model_parallel_rank
label_desc: Use image node_id 3 for calling a global function with example usage: parse_weights(weight_dict, parent_key, total, converted, translator) without return types