code: def _get_span_replace_glob_and_regex(
      range_config: range_config_pb2.RangeConfig,
      is_match_span: bool,
      is_match_date: bool,
      span_width_str: Optional[str],
  ) -> Union[str, List[str]]:
      """Replace span or date spec if static range RangeConfig is provided."""
      if range_config.HasField("static_range"):
          if is_match_span:
              # If using RangeConfig.static_range, replace span spec in patterns
              # with given span from static range.
              span_str = str(
                  range_config.static_range.start_span_number
              )
              if span_width_str:
                  span_width_int = int(span_width_str)
                  if span_width_int < len(span_str):
                      raise ValueError(
                          "Span spec width is less than number of digits in span: (%s, %s)"
                          % (span_width_int, span_str)
                      )
                  span_str = span_str.zfill(span_width_int)
              return span_str
  
          elif is_match_date:
              # If using RangeConfig.static_range, replace date specs in patterns
              # with calendar date derived from given span from static range.
              span_int = range_config.static_range.start_span_number
              year, month, day = span_number_to_date(span_int)
              date_tokens = [
                  str(year).zfill(4),
                  str(month).zfill(2),
                  str(day).zfill(2),
              ]
              return date_tokens
  
          else:
              raise ValueError(
                  "One of Span or Date should be specified."
              )
      else:
          raise ValueError(
              "Only static_range in RangeConfig is supported."
          )
  
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 15 for calling a global function with example usage: _get_span_replace_glob_and_regex(range_config, is_match_span, is_match_date, span_width_str) and returns: span_str, date_tokens