parameters: (n)
return_statement: return keep
docstring: r"""Creates a filter that keeps one of every n export versions.
  
    Args:
      n: interval size.
  
    Returns:
      A filter function that keeps exactly one path from each interval
      [0, n], (n, 2n], (2n, 3n], etc...  If more than one path exists in an
      interval the largest is kept.
docstring_summary: r"""Creates a filter that keeps one of every n export versions.
docstring_tokens: r Creates a filter that keeps one of every n export versions .
function: def one_of_every_n_export_versions(n):
    r"""Creates a filter that keeps one of every n export versions.
  
    Args:
      n: interval size.
  
    Returns:
      A filter function that keeps exactly one path from each interval
      [0, n], (n, 2n], (2n, 3n], etc...  If more than one path exists in an
      interval the largest is kept.
    """
    def keep(paths):
      keeper_map = {}  # map from interval to largest path seen in that interval
      for p in paths:
        if p.export_version is None:
          # Skip missing export_versions.
          continue
        # Find the interval (with a special case to map export_version = 0 to
        # interval 0.
        interval = math.floor(
            (p.export_version - 1) / n) if p.export_version else 0
        existing = keeper_map.get(interval, None)
        if (not existing) or (existing.export_version < p.export_version):
          keeper_map[interval] = p
      return sorted(keeper_map.values())
  
    return keep
function_tokens: def one_of_every_n_export_versions ( n ) : def keep ( paths ) : keeper_map = { } # map from interval to largest path seen in that interval for p in paths : if p . export_version is None : # Skip missing export_versions. continue # Find the interval (with a special case to map export_version = 0 to # interval 0. interval = math . floor ( ( p . export_version - 1 ) / n ) if p . export_version else 0 existing = keeper_map . get ( interval , None ) if ( not existing ) or ( existing . export_version < p . export_version ) : keeper_map [ interval ] = p return sorted ( keeper_map . values ( ) ) return keep