code: def validate_objects_sharding_integrity(
      sharded_objects: List[ShardedObject],
  ):
      """Ensure uniqueness of saved objects."""
      local_sh_objs = [
          sh_obj.without_data() for sh_obj in sharded_objects
      ]
      all_sh_objs = [None] * torch.distributed.get_world_size()
      torch.distributed.all_gather_object(all_sh_objs, local_sh_objs)
      if torch.distributed.get_rank() != 0:
          return
      unique_keys = [
          sh_obj.unique_key
          for sh_obj in chain.from_iterable(all_sh_objs)
          if is_main_replica(sh_obj.replica_id)
      ]
      if len(unique_keys) != len(set(unique_keys)):
          duplicates = {
              k: cnt
              for k, cnt in Counter(unique_keys).items()
              if cnt > 1
          }
          logger.error(
              f"Duplicate ShardedObject keys and counts: {duplicates}"
          )
          raise CheckpointingException(
              f"Duplicate ShardedObject keys: {list(duplicates.keys())}"
          )
  
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 14 for calling a global function with example usage: validate_objects_sharding_integrity(sharded_objects) without return types