code: def has_access_with_pk(f):
      """
      This decorator is used to check permissions on views.
  
      The implementation is very similar from
      https://github.com/dpgaspar/Flask-AppBuilder/blob/c6fecdc551629e15467fde5d06b4437379d90592/flask_appbuilder/security/decorators.py#L134
  
      The difference is that this decorator will pass the resource ID to check permissions. It allows
      fined-grained access control using resource IDs.
      """
      if hasattr(f, "_permission_name"):
          permission_str = f._permission_name
      else:
          permission_str = f.__name__
  
      def wraps(self, *args, **kwargs):
          permission_str = f"{PERMISSION_PREFIX}{f._permission_name}"
          if self.method_permission_name:
              _permission_name = self.method_permission_name.get(
                  f.__name__
              )
              if _permission_name:
                  permission_str = (
                      f"{PERMISSION_PREFIX}{_permission_name}"
                  )
          if (
              permission_str in self.base_permissions
              and self.appbuilder.sm.has_access(
                  action_name=permission_str,
                  resource_name=self.class_permission_name,
                  resource_pk=kwargs.get("pk"),
              )
          ):
              return f(self, *args, **kwargs)
          else:
              log.warning(
                  LOGMSG_ERR_SEC_ACCESS_DENIED,
                  permission_str,
                  self.__class__.__name__,
              )
              flash(as_unicode(FLAMSG_ERR_SEC_ACCESS_DENIED), "danger")
          return redirect(
              get_auth_manager().get_url_login(next=request.url)
          )
  
      f._permission_name = permission_str
      return functools.update_wrapper(wraps, f)
  
imports: from __future__ import annotations
  import functools
  import logging
  import warnings
  from functools import wraps
  from typing import TYPE_CHECKING, Callable, Sequence, TypeVar, cast
  from flask import flash, redirect, render_template, request, url_for
  from flask_appbuilder._compat import as_unicode
  from flask_appbuilder.const import FLAMSG_ERR_SEC_ACCESS_DENIED, LOGMSG_ERR_SEC_ACCESS_DENIED, PERMISSION_PREFIX
  from airflow.auth.managers.models.resource_details import AccessView, ConnectionDetails, DagAccessEntity, DagDetails, PoolDetails, VariableDetails
  from airflow.configuration import conf
  from airflow.exceptions import RemovedInAirflow3Warning
  from airflow.utils.net import get_hostname
  from airflow.www.extensions.init_auth_manager import get_auth_manager
label_desc: Use image node_id 3 for calling a global function with example usage: has_access_with_pk(f) and returns: functools, redirect, f