from typing import List
from typing import Any
from typing import Tuple


def _longest_repeat_with_size(tokens: List[Any], start: int,
                              span_len: int) -> Tuple[int, int]:
  """Get longest repeat start at some id with certain repeat size.

  For example, _longest_repeat_with_size([2,2, 3, 3, 4, 1, 5, 5], 0, 2) returns
  (0, 4)
  Args:
    tokens: list of tokens.
    start: search start index.
    span_len: length of repeating tokens.

  Returns:
    Span of longest repeating subsequence starting at start, with repeat size of
    span_len.
  """
  j = start + span_len
  while j < len(tokens):
    if tokens[j] != tokens[start + (j - start) % span_len]:
      break
    j += 1
  return (j - start) // span_len, j