code: def _state_from_conditions(
      conditions: List[Dict[str, Any]]
  ) -> Optional[State]:
      """Get the status from the pod conditions."""
      true_conditions = [
          c.get("type", "").lower()
          for c in conditions
          if c.get("status") == "True"
      ]
      detected_states = {
          CRD_STATE_DICT[c]
          for c in true_conditions
          if c in CRD_STATE_DICT
      }
      # The list below is ordered so that returning the first state detected
      # will accurately reflect the state of the job.
      states_in_order: List[State] = [
          "finished",
          "failed",
          "stopping",
          "running",
          "starting",
      ]
      for state in states_in_order:
          if state in detected_states:
              return state
      return None
  
imports: import asyncio
  import logging
  import sys
  import traceback
  from typing import Any, Dict, List, Optional, Tuple, Union
  import kubernetes_asyncio
  import urllib3
  from kubernetes_asyncio import watch
  from kubernetes_asyncio.client import ApiException, BatchV1Api, CoreV1Api, CustomObjectsApi, V1PodStatus
  import wandb
  from wandb.sdk.launch.agent import LaunchAgent
  from wandb.sdk.launch.errors import LaunchError
  from wandb.sdk.launch.runner.abstract import State, Status
  from wandb.sdk.launch.utils import get_kube_context_and_api_client
label_desc: Use image node_id 5 for calling a global function with example usage: _state_from_conditions(conditions) and returns: None, state