code: def static_range(
      artifacts,
      *,
      start_span_number: int = -1,
      end_span_number: int = -1,
      keep_all_versions: bool = False,
      exclude_span_numbers: Sequence[int] = (),
      min_spans: Optional[int] = None,
  ):
      """Returns artifacts with spans in [start_span, end_span] inclusive.
  
      This resolver function is based on the span-version semantics, which only
      considers the latest version of each span. If you want to keep all versions,
      then set keep_all_versions=True. Input artifacts must have both "span" int
      property and "version" int property.
  
      Please note that the spans in exclude_span_numbers are excluded AFTER getting
      the artifacts with spans in the range.
  
      If there are less than min_spans unique spans present in the resolved
      artifacts, then the component execution will be skipped.
  
      Corresponds to StaticRange in TFX.
  
      Example usage:
  
        Consider 8 artifacts with:
          spans    = [0, 1, 2, 3, 3, 5, 7, 10]
          versions = [0, 0, 0, 0, 3, 0, 0, 0]
  
        static_range(
          end_span_number=5,
          keep_all_versions=False,
          exclude_span_numbers=[2])
  
        Because start_span_number = -1, it is set to the smallest span, 0.
  
        Spans in the range [0, 5] will be considered.
  
        Because keep_all_versions=False, only the artifact with span=3 and version=3
        will be considered, even though there are two artifacts with span=3.
  
        Because exclude_span_numbers=[2], the artifacts with span=2 will not be
        kept, even though it is in the range.
  
        min_spans is None but end_span_number < 0, so min_spans is not automatically
        set.
  
        The artifacts that will be returned are:
          spans    = [0, 1, 3, 5]
          versions = [0, 0, 3, 0]
  
      Args:
        artifacts: The artifacts to filter.
        start_span_number: The smallest span number to keep, inclusive. If < 0, set
          to the smallest span in the artifacts.
        end_span_number: The largest span number to keep, inclusive. If < 0, set to
          the largest span in the artifacts.
        keep_all_versions: If true, all artifacts with spans in the range are kept.
          If false then if multiple artifacts have the same span, only the span with
          the latest version is kept. Defaults to False.
        exclude_span_numbers: The span numbers to exclude.
        min_spans: Minimum number of desired example spans in the range. If
          min_spans is None, and if both end_span_number and start_span_number are
          positive, it is set to end_span_number - start_span_number + 1. Else if
          min_spans is None, it is set to -1, meaning all unique spans will be
          considered.
  
      Returns:
        Artifacts with spans in [start_span, end_span] inclusive.
      """
      resolved_artifacts = ops.StaticSpanRange(
          artifacts,
          start_span=start_span_number,
          end_span=end_span_number,
          keep_all_versions=keep_all_versions,
      )
      if exclude_span_numbers:
          resolved_artifacts = ops.ExcludeSpans(
              resolved_artifacts, denylist=exclude_span_numbers
          )
  
      if min_spans is None:
          # We check that start_span_number and end_span_number are positive to ensure
          # min_spans is well defined. Else, it is set to -1, meaning all the unique
          # spans will be considered.
          if start_span_number >= 0 and end_span_number >= 0:
              min_spans = end_span_number - start_span_number + 1
  
              # Decrement min_spans by the number of spans in exclude_span_numbers that
              # are in the range [start_span_number, end_span_number].
              num_excluded_spans = 0
              for excluded_span in exclude_span_numbers:
                  if (
                      excluded_span >= start_span_number
                      and excluded_span <= end_span_number
                  ):
                      num_excluded_spans += 1
              min_spans -= num_excluded_spans
  
              logging.warning(
                  "min_spans for static_range(...) was not set and is being set to "
                  "end_span_number - start_span_number + 1 - "
                  "(number of excluded spans in the range [start_span, end_span]) = "
                  "%s - %s + 1 - %s = %s.",
                  end_span_number,
                  start_span_number,
                  num_excluded_spans,
                  min_spans,
              )
          else:
              min_spans = -1
              logging.warning(
                  "min_spans for static_range(...) was not set and is being set to -1, "
                  "meaning static_range(...) will never throw a SkipSignal."
              )
  
      return ops.SkipIfLessThanNSpans(resolved_artifacts, n=min_spans)
  
imports: from typing import Optional, Sequence, Union
  from absl import logging
  from tfx.dsl.input_resolution import resolver_function
  from tfx.dsl.input_resolution.ops import ops
  from tfx.types import artifact
  from tfx.types import channel
label_desc: Use image node_id 3 for calling a global function with example usage: static_range(artifacts) and returns: ops