code: def _wait_for_instance(
      api_client: LambdaAPIClient,
      instance_id: str,
  ) -> Dict:
      for _ in range(_WAIT_FOR_INSTANCE_ATTEMPTS):
          instance_info = _get_instance_info(api_client, instance_id)
          if (
              instance_info is None
              or instance_info["status"] != "booting"
          ):
              return instance_info
          time.sleep(_WAIT_FOR_INSTANCE_INTERVAL)
  
imports: import hashlib
  import subprocess
  import tempfile
  import time
  from threading import Thread
  from typing import Dict, List, Optional, Tuple
  from pydantic import BaseModel
  from dstack._internal.core.backends.base.compute import Compute, get_instance_name, get_shim_commands
  from dstack._internal.core.backends.base.offers import get_catalog_offers
  from dstack._internal.core.backends.lambdalabs.api_client import LambdaAPIClient
  from dstack._internal.core.backends.lambdalabs.config import LambdaConfig
  from dstack._internal.core.models.backends.base import BackendType
  from dstack._internal.core.models.instances import InstanceAvailability, InstanceOffer, InstanceOfferWithAvailability, LaunchedInstanceInfo
  from dstack._internal.core.models.runs import Job, Requirements, Run
label_desc: Use image node_id 5 for calling a global function with example usage: _wait_for_instance(api_client, instance_id) and returns: instance_info