code: def _load_user_from_job_metadata(
      job_metadata: dict[str, Any]
  ) -> User:
      if user_id := job_metadata.get("user_id"):
          # logged in user
          user = security_manager.get_user_by_id(user_id)
      elif guest_token := job_metadata.get("guest_token"):
          # embedded guest user
          user = security_manager.get_guest_user_from_token(guest_token)
          del job_metadata["guest_token"]
      else:
          # default to anonymous user if no user is found
          user = security_manager.get_anonymous_user()
      return user
  
file_path: superset/superset/tasks/async_queries.py
imports: from __future__ import annotations
  import copy
  import logging
  from typing import Any, cast, TYPE_CHECKING
  from celery.exceptions import SoftTimeLimitExceeded
  from flask import current_app, g
  from flask_appbuilder.security.sqla.models import User
  from marshmallow import ValidationError
  from superset.charts.schemas import ChartDataQueryContextSchema
  from superset.exceptions import SupersetVizException
  from superset.extensions import async_query_manager, cache_manager, celery_app, security_manager
  from superset.utils.cache import generate_cache_key, set_and_log_cache
  from superset.utils.core import override_user
  from superset.views.utils import get_datasource_info, get_viz
label_desc: Use image node_id 3 for calling a global function with example usage: _load_user_from_job_metadata(job_metadata) and returns: user