code: def load(
      self,
      checkpoint_path: PathLike,
      inference_data_type: Optional[Union[str, torch.dtype]] = None,
      config: Optional[GptInitModelParameters] = None,
      device: Optional[Union[str, int, torch.device]] = None,
  ):
      checkpoint_path = Path(checkpoint_path)
      device = device or comm.get_device()
      config = config or self.config
  
      compute_dtype = to_torch_dtype(inference_data_type or self.dtype)
  
      self.weight = GptLayerWeights.from_config(config)
      self.weight.load(
          checkpoint_path,
          compute_dtype,
          config.weights_data_type,
          device,
      )
  
      self.context_decoder.set_weight(self.weight)
      self.decoder.set_weight(self.weight)
  
      weight_dtype = to_numpy_dtype(config.weights_data_type)
  
      def _safe_load_from_bin(param: torch.nn.Parameter, fname):
          if (checkpoint_path / fname).exists():
              # np_w is 1-D array since a bin file doesn't have shape info.
              w_ = np.fromfile(
                  checkpoint_path / fname, dtype=weight_dtype
              )
              param.data = (
                  torch.from_numpy(w_)
                  .reshape(param.data.shape)
                  .to(compute_dtype)
              )
          else:
              raise FileNotFoundError(f"Faile to load {fname}")
  
      def _safe_load_lm_head_from_bin(param, fname, ctype):
          if (checkpoint_path / fname).exists():
              shape = (
                  self.vocab_size,
                  self.config.head_num * self.config.size_per_head,
              )
              # np_w is 1-D array since a bin file doesn't have shape info.
              w_ = np.fromfile(
                  checkpoint_path / fname, dtype=weight_dtype
              )
              param.data = param.data.to(ctype)
              param.data[: self.vocab_size, :] = (
                  torch.from_numpy(w_).reshape(shape).to(ctype)
              )
          else:
              print(f"Faile to load {fname}")
              torch.nn.init.normal_(param).to(compute_dtype)
          self._mask_padded_vocab_weights(param)
  
      # pylint:disable=line-too-long
      if comm.is_pipeline_group_first():
          _safe_load_lm_head_from_bin(
              self.word_embedding.weight, "model.wte.bin", compute_dtype
          )
          self._mask_padded_vocab_weights(self.word_embedding.weight)
          if self.position_encoding is not None:
              _safe_load_from_bin(
                  self.position_encoding.weight, "model.wpe.bin"
              )
          if self.pre_decoder_layernorm is not None:
              _safe_load_from_bin(
                  self.pre_decoder_layernorm.weight,
                  "model.pre_decoder_layernorm.weight.bin",
              )
              _safe_load_from_bin(
                  self.pre_decoder_layernorm.bias,
                  "model.pre_decoder_layernorm.bias.bin",
              )
      if comm.is_pipeline_group_last():
          if self.post_decoder_layernorm is not None:
              _safe_load_from_bin(
                  self.post_decoder_layernorm.weight,
                  "model.final_layernorm.weight.bin",
              )
              _safe_load_from_bin(
                  self.post_decoder_layernorm.bias,
                  "model.final_layernorm.bias.bin",
              )
          if (checkpoint_path / "model.lm_head.weight.bin").exists():
              _safe_load_lm_head_from_bin(
                  self.lm_head.weight,
                  "model.lm_head.weight.bin",
                  self.lm_head_ctype,
              )
          else:
              if self.use_fp32_to_compute_logit:
                  _safe_load_lm_head_from_bin(
                      self.lm_head.weight,
                      "model.wte.bin",
                      torch.float32,
                  )
              else:
                  # In this branch we can share the pre and post
                  # decoder embeddings, but ONLY pipeline size is 1.
                  # When pipeline size > 1, these two weights will end up on
                  # different GPUs, so we must load the
                  # post decoder weight again (else case).
                  if comm.get_pipeline_para_size() == 1:
                      self.lm_head.weight = self.word_embedding.weight
                  else:
                      _safe_load_lm_head_from_bin(
                          self.lm_head.weight,
                          "model.wte.bin",
                          compute_dtype,
                      )
  
      self.to(device)
  
imports: import math
  from abc import abstractmethod
  from pathlib import Path
  from typing import List, Literal, Optional, Union
  import os
  import numpy
  from .None import comm
  from .None import profiler
  from .gpt import GptInitModelParameters
  from nebullvm.optional_modules.torch import torch
label_desc: Use image node_id 3 for calling the Gpt obj's underlying member method code with example usage: obj.load(checkpoint_path, inference_data_type, config, device) without return types