code: def _collect_artifacts(
      client: LightningClient,
      project_id: str,
      prefix: str = "",
      page_token: Optional[str] = "",
      cluster_id: Optional[str] = None,
      page_size: int = 100_000,
      tokens=None,
      include_download_url: bool = False,
  ) -> Generator:
      if tokens is None:
          tokens = []
  
      if cluster_id is None:
          clusters = (
              client.projects_service_list_project_cluster_bindings(
                  project_id
              )
          )
          for cluster in clusters.clusters:
              yield from _collect_artifacts(
                  client,
                  project_id,
                  prefix=prefix,
                  cluster_id=cluster.cluster_id,
                  page_token=page_token,
                  tokens=tokens,
                  page_size=page_size,
                  include_download_url=include_download_url,
              )
      else:
          if page_token in tokens:
              return
  
          # Note: This is triggered when the request is wrong.
          # This is currently happening due to looping through the user clusters.
          with contextlib.suppress(
              lightning_cloud.openapi.rest.ApiException
          ):
              response = client.lightningapp_instance_service_list_project_artifacts(
                  project_id,
                  prefix=prefix,
                  cluster_id=cluster_id,
                  page_token=page_token,
                  include_download_url=include_download_url,
                  page_size=str(page_size),
              )
              for artifact in response.artifacts:
                  if ".lightning-app-sync" in artifact.filename:
                      continue
                  yield artifact
  
              if response.next_page_token:
                  tokens.append(page_token)
                  yield from _collect_artifacts(
                      client,
                      project_id,
                      prefix=prefix,
                      cluster_id=cluster_id,
                      page_token=response.next_page_token,
                      tokens=tokens,
                  )
  
imports: import contextlib
  import os
  import sys
  from contextlib import nullcontext
  from typing import Generator, List, Optional
  import click
  import lightning_cloud
  import rich
  from lightning_cloud.openapi import Externalv1LightningappInstance
  from rich.console import Console
  from rich.live import Live
  from rich.spinner import Spinner
  from rich.text import Text
  from lightning.app.cli.connect.app import _LIGHTNING_CONNECTION_FOLDER
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.cli_helpers import _error_and_exit
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 4 for calling a global function with example usage: _collect_artifacts(client, project_id, prefix, page_token, cluster_id, page_size, tokens, include_download_url) without return types