code: def _resolve_resource(
      registry_url: str,
      name: str,
      version_arg: str,
      resource_type: str,
      raise_error: bool = True,
  ) -> Dict[str, str]:
      gallery_entries = []
      try:
          response = requests.get(registry_url)
          data = response.json()
  
          if resource_type == "app":
              gallery_entries = [
                  a for a in data["apps"] if a["canDownloadSourceCode"]
              ]
  
          elif resource_type == "component":
              gallery_entries = data["components"]
      except requests.ConnectionError:
          sys.tracebacklimit = 0
          raise SystemError(
              f"""
          Network connection error, could not load list of available Lightning {resource_type}s.
  
          Try again when you have a network connection!
          """
          )
  
      entries = []
      all_versions = []
      for x in gallery_entries:
          if name == x["name"]:
              entries.append(x)
              all_versions.append(x["version"])
  
      if len(entries) == 0:
          if raise_error:
              raise SystemExit(
                  f"{resource_type}: '{name}' is not available on ⚡ Lightning AI ⚡"
              )
  
          return None
  
      entry = None
      if version_arg == "latest":
          entry = max(entries, key=lambda app: Version(app["version"]))
      else:
          for e in entries:
              if e["version"] == version_arg:
                  entry = e
                  break
      if entry is None and raise_error:
          if raise_error:
              raise Exception(
                  f"{resource_type}: 'Version {version_arg} for {name}' is not available on ⚡ Lightning AI ⚡. "
                  f"Here is the list of all availables versions:{os.linesep}{os.linesep.join(all_versions)}"
              )
          return None
  
      return entry
  
imports: import os
  import re
  import shutil
  import subprocess
  import sys
  from typing import Dict, Optional, Tuple
  import click
  import requests
  from packaging.version import Version
  from lightning.app.core.constants import LIGHTNING_APPS_PUBLIC_REGISTRY, LIGHTNING_COMPONENT_PUBLIC_REGISTRY
  from lightning.app.utilities.app_helpers import Logger
label_desc: Use image node_id 17 for calling a global function with example usage: _resolve_resource(registry_url, name, version_arg, resource_type, raise_error) and returns: entry, None, None