code: def purge_archives(base_dir: str, retain_latest: bool = False) -> None:
          
  
          LOGGER.debug('purge_archives >>> base_dir: %s, retain_latest: %s', base_dir, retain_latest)
  
          if isdir(base_dir):
              timestamps = sorted([int(t) for t in listdir(base_dir) if t.isdigit()])
              if retain_latest and timestamps:
                  timestamps.pop()
              for timestamp in timestamps:
                  timestamp_dir = join(base_dir, str(timestamp))
                  rmtree(timestamp_dir)
                  LOGGER.info('Purged archive cache directory %s', timestamp_dir)
  
          LOGGER.debug('purge_archives <<<')
docs: Erase all (or nearly all) cache archives.
  
          :param base_dir: archive base directory
          :param retain_latest: retain latest archive if present, purge all others