code: def invalidate_cache(user, size=None):
      
      sizes = set(AUTO_GENERATE_AVATAR_SIZES)
      if size is not None:
          sizes.add(size)
      for prefix in cached_funcs:
          for size in sizes:
              cache.delete(get_cache_key(user, size, prefix))
docs: Function to be called when saving or changing an user's avatars.