code: def load_sharded_objects(
      sharded_state_dict: ShardedStateDict, checkpoint_dir: Path
  ):
      sharded_objects, sharded_state_dict = extract_matching_values(
          sharded_state_dict, lambda v: isinstance(v, ShardedObject)
      )
  
      def load_sharded_object(sh_obj: ShardedObject):
          sh_obj.data = None
          load_path = (checkpoint_dir / sh_obj.unique_key).with_suffix(
              ".pt"
          )
          try:
              loaded_obj = torch.load(load_path)
          except FileNotFoundError as e:
              err_msg = f"Object shard {load_path} not found"
              obj_subdir = checkpoint_dir / sh_obj.key
              if obj_subdir.exists():
                  obj_files = [f.name for f in obj_subdir.iterdir()]
                  logger.debug(
                      f"{err_msg}. Object {sh_obj.key} directory content: {obj_files}"
                  )
              else:
                  ckpt_files = [
                      f.name for f in checkpoint_dir.iterdir()
                  ]
                  logger.debug(
                      f"{err_msg}. Object {sh_obj.key} directory does not exist. Checkpoint directory content: {ckpt_files}"
                  )
              raise CheckpointingException(err_msg) from e
          return loaded_obj
  
      return (
          dict_list_map_inplace(load_sharded_object, sharded_objects),
          sharded_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 4 for calling a global function with example usage: load_sharded_objects(sharded_state_dict, checkpoint_dir) and returns: dict_list_map_inplace,  sharded_state_dict, loaded_obj