code: def __init__(
      self, dir, tp_degree=None, pp_degree=None, dp_degree=None
  ):
      self.dir = dir
      self._validate_folder(dir)
  
      self.zero_checkpoint = ZeROCheckpoint(dir)
  
      self.file_list = get_files(dir)
      self.layer_files = get_files_with_prefix(
          self.file_list, LAYER_FILE_PREFIX
      )
      self.mp_rank_files = get_files_with_prefix(
          self.file_list, MODEL_FILE_PREFIX
      )
  
      self.layer_keys = self._get_layer_keys()
      self.layer_count = len(self.layer_keys)
  
      self.tp_degree = (
          self.zero_checkpoint.get_src_tp_degree()
          if tp_degree is None
          else tp_degree
      )
      self.pp_degree = (
          self.zero_checkpoint.get_src_pp_degree()
          if pp_degree is None
          else pp_degree
      )
      self.dp_degree = (
          self.zero_checkpoint.get_src_dp_degree()
          if dp_degree is None
          else dp_degree
      )
  
      self.original_world_size = (
          self.zero_checkpoint.get_src_tp_degree()
          * self.zero_checkpoint.get_src_pp_degree()
          * self.zero_checkpoint.get_src_dp_degree()
      )
      self.world_size = self.tp_degree * self.pp_degree * self.dp_degree
  
      self.old_2d_map = meg_2d_parallel_map(
          self.zero_checkpoint.get_src_pp_degree(),
          self.zero_checkpoint.get_src_tp_degree(),
      )
      self.old_2d_map.simple_init()
      self.new_2d_map = reshape_meg_2d_parallel(
          old_pp_degree=self.zero_checkpoint.get_src_pp_degree(),
          old_tp_degree=self.zero_checkpoint.get_src_tp_degree(),
          new_pp_degree=self.pp_degree,
          new_tp_degree=self.tp_degree,
      )
  
      if (
          self.is_change_pp_degree()
          or self.is_change_tp_degree()
          or self.is_change_dp_degree()
      ):
          self.zero_checkpoint.reshape(
              model_3d_desc(
                  self.pp_degree, self.tp_degree, self.dp_degree
              )
          )
  
      self.global_state = {}
  
      self._sanity_check()
      self.pp_to_transformer_map = self._build_pp_transformer_map()
      self.transformer_file_map = self._build_transformer_file_map()
      self.tp_to_embedding_map = self._build_tp_other_layer_map(
          EMBEDDING_LAYER_INDEX
      )
      self.tp_to_final_norm_map = self._build_tp_other_layer_map(
          FINAL_LAYER_NORM_INDEX
      )
      self._build_global_state()
  
imports: import os
  from typing import Dict
  import torch
  from .reshape_3d_utils import model_3d_desc
  from .reshape_utils import basic_folder_validation, merge_state, partition_data, get_files, get_files_with_prefix
  from .constants import MODEL_FILE_PREFIX, LAYER_FILE_PREFIX
  from .reshape_meg_2d import reshape_meg_2d_parallel, meg_2d_parallel_map
  from .zero_checkpoint import ZeROCheckpoint
  from .constants import *
label_desc: Use image node_id 1 to create a new DeepSpeedCheckpoint object from inherited base classes: object with example: obj = DeepSpeedCheckpoint(dir, tp_degree, pp_degree, dp_degree)