code: def calculate_splits_fingerprint_span_and_version(
      input_base_uri: str,
      splits: Iterable[example_gen_pb2.Input.Split],
      range_config: Optional[range_config_pb2.RangeConfig] = None,
  ) -> Tuple[str, int, Optional[int]]:
      """Calculates the fingerprint of files in a URI matching split patterns.
  
      If a pattern has the {SPAN} placeholder or the Date spec placeholders, {YYYY},
      {MM}, and {DD}, and optionally, the {VERSION} placeholder, attempts to find
      aligned values that results in all splits having the target span and most
      recent version for that span.
  
      Args:
        input_base_uri: The base path from which files will be searched.
        splits: An iterable collection of example_gen_pb2.Input.Split objects.
        range_config: An instance of range_config_pb2.RangeConfig, which specifies
          which spans to consider when finding the most recent span and version. If
          unset, search for latest span number with no restrictions.
  
      Returns:
        A Tuple of [fingerprint, select_span, select_version], where select_span
        is either the value matched with the {SPAN} placeholder, the value mapped
        from matching the calendar date with the date placeholders {YYYY}, {MM},
        {DD} or 0 if a placeholder wasn't specified, and where select_version is
        either the value matched with the {VERSION} placeholder, or None if the
        placeholder wasn't specified. Note that this function will update the
        {SPAN} or Date tags as well as the {VERSION} tags in the split configs to
        actual Span and Version numbers.
      """
  
      split_fingerprints = []
      select_span = 0
      select_version = None
      # Calculate the fingerprint of files under input_base_uri.
      for split in splits:
          logging.info(
              "select span and version = (%s, %s)",
              select_span,
              select_version,
          )
          # Find most recent span and version for this split.
          target_span, target_version = _get_target_span_version(
              input_base_uri, split, range_config=range_config
          )
  
          # TODO(b/162622803): add default behavior for when version spec not present.
          target_span = target_span or 0
  
          logging.info(
              "latest span and version = (%s, %s)",
              target_span,
              target_version,
          )
  
          if select_span == 0 and select_version is None:
              select_span = target_span
              select_version = target_version
  
          # Check if latest span and version are the same over all splits.
          if select_span != target_span:
              raise ValueError(
                  "Latest span should be the same for each split"
              )
          if select_version != target_version:
              raise ValueError(
                  "Latest version should be the same for each split"
              )
  
          # Calculate fingerprint.
          pattern = os.path.join(input_base_uri, split.pattern)
          split_fingerprint = io_utils.generate_fingerprint(
              split.name, pattern
          )
          split_fingerprints.append(split_fingerprint)
  
      fingerprint = "\n".join(split_fingerprints)
      return fingerprint, select_span, select_version
  
imports: import datetime
  import os
  import re
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  from absl import logging
  import numpy
  from tfx.dsl.io import fileio
  from tfx.proto import example_gen_pb2
  from tfx.proto import range_config_pb2
  from tfx.utils import io_utils
  from google.protobuf import json_format
  from tensorflow.core.example import example_pb2
  from tensorflow.core.example import feature_pb2
label_desc: Use image node_id 18 for calling a global function with example usage: calculate_splits_fingerprint_span_and_version(input_base_uri, splits, range_config) and returns: fingerprint,  select_span,  select_version