code: def download_opt_weights_old(model_name, path):
      """Download weights from huggingface."""
      import torch
      from transformers import OPTForCausalLM, BloomForCausalLM
  
      if "/" in model_name:
          model_name = model_name.split("/")[1].lower()
      path = os.path.join(path, f"{model_name}-np")
      path = os.path.abspath(os.path.expanduser(path))
  
      if "opt" in model_name:
          hf_model_name = "facebook/" + model_name
          model_class = OPTForCausalLM
      elif "bloom" in model_name:
          hf_model_name = "bigscience/" + model_name
          model_class = BloomForCausalLM
      elif "galactica" in model_name:
          hf_model_name = "facebook/" + model_name
      else:
          raise ValueError("Invalid model name: {model_name}")
  
      print(
          f"Load the pre-trained pytorch weights of {model_name} from huggingface. "
          f"The downloading and cpu loading can take dozens of minutes. "
          f"If it seems to get stuck, you can monitor the progress by "
          f"checking the memory usage of this process."
      )
  
      disable_torch_init()
      model = model_class.from_pretrained(
          hf_model_name, torch_dtype=torch.float16, _fast_init=True
      )
      restore_torch_init()
  
      os.makedirs(path, exist_ok=True)
  
      print(f"Convert the weights to numpy format under {path} ...")
      if "opt" in model_name:
          for name, param in tqdm(list(model.model.named_parameters())):
              name = name.replace(
                  "decoder.final_layer_norm", "decoder.layer_norm"
              )
              param_path = os.path.join(path, name)
              with open(param_path, "wb") as f:
                  np.save(f, param.cpu().detach().numpy())
      elif "galactica" in model_name:
          for name, param in tqdm(list(model.model.named_parameters())):
              name = name.replace(
                  "decoder.final_layer_norm", "decoder.layer_norm"
              )
              param_path = os.path.join(path, name)
              with open(param_path, "wb") as f:
                  np.save(f, param.cpu().detach().numpy())
      elif "bloom" in model_name:
          for name, param in tqdm(
              list(model.transformer.named_parameters())
          ):
              param_path = os.path.join(path, name)
              with open(param_path, "wb") as f:
                  np.save(f, param.cpu().detach().numpy())
      else:
          raise ValueError("Invalid model name: {model_name}")
  
file_path: H2O/h2o_flexgen/flexgen/opt_config.py
imports: import argparse
  import dataclasses
  import glob
  import os
  import shutil
  import numpy
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: download_opt_weights_old(model_name, path) without return types