docstr: Restores module/model's weights
docstr_tok: ["Restores","module\/model","'s","weights"]
code: def restore_weights(self, restore_path: str):
      """Restores module/model's weights"""
      logging.info(f"Restoring weights from {restore_path}")
  
      if not os.path.exists(restore_path):
          logging.warning(f"Path {restore_path} not found")
          return
  
      pretrained_dict = torch.load(restore_path)
  
      # backward compatibility with NeMo0.11
      if "state_dict" in pretrained_dict.keys():
          pretrained_dict = pretrained_dict["state_dict"]
  
      # remove prefix from pretrained dict
      m = re.match("^gpt.*?\.", list(pretrained_dict.keys())[0])
      if m:
          prefix = m.group(0)
          pretrained_dict = {
              k[len(prefix) :]: v for k, v in pretrained_dict.items()
          }
      model_dict = self.state_dict()
      pretrained_dict = {
          k: v for k, v in pretrained_dict.items() if k in model_dict
      }
  
      # starting with transformers 3.1.0, embeddings.position_ids is added to the model's state dict and could be
      # missing in checkpoints trained with older transformers version
      if (
          "embeddings.position_ids" in model_dict
          and "embeddings.position_ids" not in pretrained_dict
      ):
          pretrained_dict["embeddings.position_ids"] = model_dict[
              "embeddings.position_ids"
          ]
  
      model_dict.update(pretrained_dict)
      self.load_state_dict(model_dict)
      logging.info(
          f"Weights for {type(self).__name__} restored from {restore_path}"
      )
  
file_path: NeMo/nemo/collections/nlp/modules/common/gpt_module.py
imports: import os
  import re
  from typing import Dict, Optional
  import torch
  from nemo.core.classes import NeuralModule
  from nemo.core.classes.exportable import Exportable
  from nemo.core.neural_types import ChannelType, FloatType, IntType, MaskType, NeuralType, StringType, VoidType
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling the GPTModule obj's underlying member method code with example usage: obj.restore_weights(restore_path) without return types