code: def compute_split_info(
      *,
      out_dir: Optional[epath.PathLike] = None,
      filename_template: naming.ShardedFileTemplate,
  ) -> Sequence[split_lib.SplitInfo]:
      """Compute the split info on the given files.
  
      Compute the split info (num shards, num examples,...) metadata required
      by `tfds.folder_dataset.write_metadata`.
  
      See documentation for usage:
      https://www.tensorflow.org/datasets/external_tfrecord
  
      Args:
        out_dir: Output directory where to save the metadata. It should be available
          from the apache beam workers. If not set, apache beam won't be used (only
          available with some file formats).
        filename_template: filename template of the splits. The template should have
          set the data_dir because this is used to compute the split info.
  
      Returns:
        split_infos: The list of `tfds.core.SplitInfo`.
      """
      # Auto-detect the splits from the files
      split_files = _extract_split_files(filename_template)
      print("Auto-detected splits:")
      for split_name, file_infos in split_files.items():
          print(f" * {split_name}: {file_infos[0].num_shards} shards")
  
      if out_dir is not None:
          # Launch the beam pipeline to compute the split infos.
          split_infos = _compute_split_statistics_beam(
              split_files=split_files,
              out_dir=out_dir,
              filename_template=filename_template,
          )
      else:
          # Compute split infos locally.
          split_infos = _compute_split_statistics(
              split_files=split_files,
              filename_template=filename_template,
          )
  
      print("Computed split infos: ")
      pprint.pprint(split_infos)
  
      return split_infos
  
imports: import collections
  from collections.abc import Mapping, Sequence, Set
  import dataclasses
  import functools
  import itertools
  import os
  import pprint
  from typing import Optional, Type, Union, cast
  from etils import epath
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.proto import dataset_info_pb2
  from tensorflow_datasets.core.utils.lazy_imports_utils import apache_beam
  from tensorflow_datasets.core.utils.lazy_imports_utils import array_record_data_source
  from google.protobuf import json_format
label_desc: Use image node_id 3 for calling a global function with example usage: compute_split_info() and returns: split_infos