code: def _get_newer_version() -> Optional[str]:
      """Check PyPI for newer versions of ``lightning``, returning the newest version if different from the current or
      ``None`` otherwise."""
      if packaging.version.parse(__version__).is_prerelease:
          return None
      try:
          response = requests.get(
              f"https://pypi.org/pypi/{__package_name__}/json"
          )
          response_json = response.json()
          releases = response_json["releases"]
          if __version__ not in releases:
              # Always return None if not installed from PyPI (e.g. dev versions)
              return None
          latest_version = response_json["info"]["version"]
          parsed_version = packaging.version.parse(latest_version)
          is_invalid = (
              response_json["info"]["yanked"]
              or parsed_version.is_devrelease
              or parsed_version.is_prerelease
          )
          return (
              None
              if __version__ == latest_version or is_invalid
              else latest_version
          )
      except Exception:
          # Return None if any exception occurs
          return None
  
imports: import contextlib
  import functools
  import json
  import os
  import re
  import subprocess
  import sys
  from typing import Dict, Optional
  import arrow
  import click
  import packaging
  import requests
  import rich
  from lightning_cloud.openapi import Externalv1LightningappInstance
  from lightning.app import __package_name__, __version__
  from lightning.app.core.constants import APP_SERVER_PORT
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 7 for calling a global function with example usage: _get_newer_version() and returns: None, unknown, None, None