code: def _cluster_from_lit_resource(
      lit_resource: Union[Externalv1LightningappInstance, V1CloudSpace]
  ) -> Union[V1GetClusterResponse, Externalv1Cluster]:
      client = LightningClient()
      if isinstance(lit_resource, Externalv1LightningappInstance):
          return client.cluster_service_get_cluster(
              lit_resource.spec.cluster_id
          )
  
      clusters = client.cluster_service_list_clusters()
      for cluster in clusters.clusters:
          if cluster.id == clusters.default_cluster:
              return cluster
      return None
  
imports: import concurrent
  import contextlib
  import os
  import sys
  from functools import partial
  from multiprocessing.pool import ApplyResult
  from pathlib import Path
  from textwrap import dedent
  from typing import Any, Optional, Tuple, Union
  import click
  import requests
  import urllib3
  from lightning_cloud.openapi import Externalv1Cluster, Externalv1LightningappInstance, ProjectIdStorageBody, V1CloudSpace, V1GetClusterResponse
  from rich.live import Live
  from rich.progress import BarColumn, DownloadColumn, Progress, TaskID, TextColumn
  from rich.spinner import Spinner
  from rich.text import Text
  from lightning.app.cli.commands.ls import _collect_artifacts, _get_prefix
  from lightning.app.cli.commands.pwd import _pwd
  from lightning.app.source_code import FileUploader
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.auth import _AuthTokenGetter
  from lightning.app.utilities.cli_helpers import _error_and_exit
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 14 for calling a global function with example usage: _cluster_from_lit_resource(lit_resource) and returns: None, client, cluster