code: def cache_chart_thumbnail(
      current_user: Optional[str],
      chart_id: int,
      force: bool = False,
      window_size: Optional[WindowSize] = None,
      thumb_size: Optional[WindowSize] = None,
  ) -> None:
      # pylint: disable=import-outside-toplevel
      from superset.models.slice import Slice
  
      if not thumbnail_cache:
          logger.warning("No cache set, refusing to compute")
          return None
      chart = cast(Slice, Slice.get(chart_id))
      if not chart:
          logger.warning(
              "No chart found, skip computing chart thumbnail"
          )
          return None
      url = get_url_path("Superset.slice", slice_id=chart.id)
      logger.info("Caching chart: %s", url)
      _, username = get_executor(
          executor_types=current_app.config["THUMBNAIL_EXECUTE_AS"],
          model=chart,
          current_user=current_user,
      )
      user = security_manager.find_user(username)
      with override_user(user):
          screenshot = ChartScreenshot(url, chart.digest)
          screenshot.compute_and_cache(
              user=user,
              cache=thumbnail_cache,
              force=force,
              window_size=window_size,
              thumb_size=thumb_size,
          )
      return None
  
file_path: superset/superset/tasks/thumbnails.py
imports: import logging
  from typing import cast, Optional
  from flask import current_app
  from superset import security_manager, thumbnail_cache
  from superset.extensions import celery_app
  from superset.tasks.utils import get_executor
  from superset.utils.core import override_user
  from superset.utils.screenshots import ChartScreenshot, DashboardScreenshot
  from superset.utils.urls import get_url_path
  from superset.utils.webdriver import WindowSize
label_desc: Use image node_id 1 for calling a global function with example usage: cache_chart_thumbnail(current_user, chart_id, force, window_size, thumb_size) and returns: None, None, None