code: def load(
      sharded_state_dict: ShardedStateDict,
      checkpoint_dir: str,
      sharded_strategy: Union[LoadShardedStrategy, None] = None,
      common_strategy: Union[LoadCommonStrategy, None] = None,
      validate_access_integrity: bool = True,
  ) -> StateDict:
      """Loading entrypoint.
  
      Arguments:
          sharded_state_dict (ShardedStateDict): state dict of the existing model
              populated with ShardedTensors. Used as a mapping to determine which
              parts of global tensors stored in the checkpoint should be loaded.
          checkpoint_dir (str): directory with the checkpoint
          sharded_strategy (LoadShardedStrategy, optional): configures loading behavior for sharded tensors
          common_strategy (LoadCommonStrategy, optional): configures loading behavior for common data
          validate_access_integrity (bool default = True): checks if each tensor shard is accessed
              exactly once (as main replica) by some process
      """
      if common_strategy is not None:
          raise NotImplementedError(
              "The only supported common strategy is torch"
          )
  
      sharded_strategy = _verify_checkpoint_and_load_strategy(
          checkpoint_dir, sharded_strategy
      )
  
      checkpoint_dir = Path(checkpoint_dir)
      common_state_dict = load_common_state_dict(checkpoint_dir)
      if not sharded_state_dict:
          return common_state_dict
  
      sharded_objects, sharded_state_dict = load_sharded_objects(
          sharded_state_dict, checkpoint_dir
      )
      merge(common_state_dict, sharded_objects)
  
      sh_ten_factories, _ = extract_matching_values(
          sharded_state_dict,
          lambda x: isinstance(x, ShardedTensorFactory),
          return_lists_as_dicts=True,
      )
      apply_factories(sharded_state_dict)
      sharded_state_dict, _ = extract_sharded_tensors_or_nonpersistent(
          sharded_state_dict
      )
      (
          sharded_state_dict,
          nonpersistent_state_dict,
      ) = extract_sharded_tensors(sharded_state_dict)
      dict_list_map_inplace(
          lambda o: o.unwrap(), nonpersistent_state_dict
      )
      merge(common_state_dict, nonpersistent_state_dict)
  
      if validate_access_integrity:
          validate_sharding_integrity(nested_values(sharded_state_dict))
  
      loaded_state_dict = sharded_strategy.load(
          sharded_state_dict, checkpoint_dir
      )
  
      loaded_state_dict = apply_factory_merges(
          loaded_state_dict, sh_ten_factories
      )
  
      merge(common_state_dict, loaded_state_dict)
      return common_state_dict
  
imports: import logging
  import os
  from collections import Counter, defaultdict
  from itertools import chain
  from pathlib import Path
  from typing import Iterable, List, Optional, Tuple, Union
  import numpy
  import torch
  from .core import CheckpointingConfig, maybe_load_config, save_config
  from .dict_utils import dict_list_map_inplace, diff, extract_matching_values, map_reduce, merge, nested_values
  from .mapping import CheckpointingException, ShardedObject, ShardedStateDict, ShardedTensor, ShardedTensorFactory, StateDict, apply_factories, apply_factory_merges, is_main_replica
  from .strategies.base import LoadCommonStrategy, LoadShardedStrategy, SaveCommonStrategy, SaveShardedStrategy, StrategyAction, get_default_strategy
  from .utils import extract_sharded_tensors, extract_sharded_tensors_or_nonpersistent
label_desc: Use image node_id 1 for calling a global function with example usage: load(sharded_state_dict, checkpoint_dir, sharded_strategy, common_strategy, validate_access_integrity) and returns: common_state_dict, common_state_dict