code: def get_filter(
      resource: KeyValueResource, key: int | UUID
  ) -> KeyValueFilter:
      try:
          filter_: KeyValueFilter = {"resource": resource.value}
          if isinstance(key, UUID):
              filter_["uuid"] = key
          else:
              filter_["id"] = key
          return filter_
      except ValueError as ex:
          raise KeyValueParseKeyError() from ex
  
file_path: superset/superset/key_value/utils.py
imports: from __future__ import annotations
  from hashlib import md5
  from secrets import token_urlsafe
  from typing import Any
  from uuid import UUID, uuid3
  import hashids
  from flask_babel import gettext
  from superset.key_value.exceptions import KeyValueParseKeyError
  from superset.key_value.types import KeyValueFilter, KeyValueResource
  from superset.utils.core import json_dumps_w_dates
label_desc: Use image node_id 2 for calling a global function with example usage: get_filter(resource, key) and returns: filter_