code: def _get_shard_specs(
      num_examples: int,
      total_size: int,
      bucket_lengths: List[int],
      filename_template: naming.ShardedFileTemplate,
      shard_config: shard_utils.ShardConfig,
  ) -> List[_ShardSpec]:
      """Returns list of _ShardSpec instances, corresponding to shards to write.
  
      Args:
        num_examples: int, number of examples in split.
        total_size: int (bytes), sum of example sizes.
        bucket_lengths: list of ints, number of examples in each bucket.
        filename_template: template to format sharded filenames.
        shard_config: the configuration for creating shards.
      """
      num_shards = shard_config.get_number_shards(
          total_size, num_examples
      )
      shard_boundaries = _get_shard_boundaries(num_examples, num_shards)
      shard_specs = []
      bucket_indexes = [str(i) for i in range(len(bucket_lengths))]
      from_ = 0
      for shard_index, to in enumerate(shard_boundaries):
          # Read the bucket indexes
          file_instructions = shard_utils.get_file_instructions(
              from_, to, bucket_indexes, bucket_lengths
          )
          shard_path = filename_template.sharded_filepath(
              shard_index=shard_index, num_shards=num_shards
          )
          index_path = _get_index_path(os.fspath(shard_path))
          shard_specs.append(
              _ShardSpec(
                  shard_index=shard_index,
                  path=os.fspath(shard_path),
                  index_path=index_path,
                  examples_number=to - from_,
                  file_instructions=file_instructions,
              )
          )
          from_ = to
      return shard_specs
  
imports: import dataclasses
  import functools
  import itertools
  import json
  import os
  from typing import Any, Iterable, List, Optional, Tuple
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import example_serializer
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import hashing
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import shuffle
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import apache_beam
label_desc: Use image node_id 3 for calling a global function with example usage: _get_shard_specs(num_examples, total_size, bucket_lengths, filename_template, shard_config) and returns: shard_specs