code: def _validate_global_plan(
      global_plan: List[SavePlan], metadata: Metadata
  ) -> bool:
      all_good = True
      for key, value in metadata.state_dict_metadata.items():
          if isinstance(value, BytesStorageMetadata):
              continue
          if len(value.size) == 0:
              continue
          chunks_volume = 0
          for chunk_idx, chunk0 in enumerate(value.chunks):
              # Compute the volume
              if not _check_box_bounds(value.size, chunk0):
                  logger.warning(
                      """
                          key:%s has out of bounds chunk:
                          tensor-size:%s chunk: %s
                      """,
                      key,
                      value.size,
                      chunk0,
                  )
                  all_good = False
              chunks_volume += reduce(operator.mul, chunk0.sizes, 1)
  
              # Check for overlap
              for chunk1 in value.chunks[chunk_idx + 1 :]:
                  if _check_box_overlap(chunk0, chunk1):
                      logger.warning(
                          "key:%s has overlapping chunks: %s %s",
                          key,
                          chunk0,
                          chunk1,
                      )
                      all_good = False
  
          # Check whether combined chunk cover the whole tensor
          tensor_volume = reduce(operator.mul, value.size, 1)
          if chunks_volume != tensor_volume:
              logger.warning(
                  """
                      key:%s invalid fill tensor-volume:
                      %s chunks-volume: %s
                  """,
                  key,
                  tensor_volume,
                  chunks_volume,
              )
              all_good = False
  
      return all_good
  
imports: import dataclasses
  import io
  import logging
  import operator
  from collections import ChainMap
  from functools import reduce
  from typing import Any, cast, Dict, List, Tuple, Union
  import torch
  from torch.distributed._shard._utils import narrow_tensor_by_index
  from torch.distributed._tensor import DTensor
  from torch.distributed.checkpoint._dedup_tensors import dedup_tensors
  from torch.distributed.checkpoint._nested_dict import FLATTEN_MAPPING, flatten_state_dict
  from torch.distributed.checkpoint._sharded_tensor_utils import _flatten_sharded_tensors
  from torch.distributed.checkpoint._traverse import set_element
  from torch.distributed.checkpoint.metadata import BytesStorageMetadata, ChunkStorageMetadata, Metadata, MetadataIndex, STATE_DICT_TYPE, STORAGE_TYPES, TensorStorageMetadata
  from torch.distributed.checkpoint.planner import LoadPlan, LoadPlanner, ReadItem, SavePlan, SavePlanner, WriteItem, WriteItemType
  from torch.distributed.checkpoint.planner_helpers import _create_default_metadata_only_plan, _create_read_items, _create_write_items, _init_state_dict
  from torch.distributed.checkpoint.utils import find_state_dict_object
label_desc: Use image node_id 8 for calling a global function with example usage: _validate_global_plan(global_plan, metadata) and returns: all_good