code: def _check_and_update_status_for_worker(
      client: docker.DockerClient,
      worker: SyftWorker,
      worker_stash: WorkerStash,
      credentials: SyftVerifyKey,
  ) -> Union[SyftWorker, SyftError]:
      worker_status = _get_worker_container_status(client, worker)
  
      if isinstance(worker_status, SyftError):
          return worker_status
  
      worker.status = worker_status
  
      worker.healthcheck = _get_healthcheck_based_on_status(
          status=worker_status
      )
  
      result = worker_stash.update(
          credentials=credentials,
          obj=worker,
      )
  
      return (
          SyftError(
              message=f"Failed to update status for worker: {worker.id}. Error: {result.err()}"
          )
          if result.is_err()
          else result.ok()
      )
  
imports: import contextlib
  from typing import List
  from typing import Tuple
  from typing import Union
  import docker
  from ...node.credentials import SyftVerifyKey
  from ...serde.serializable import serializable
  from ...store.document_store import DocumentStore
  from ...store.document_store import SyftSuccess
  from ...types.uid import UID
  from ...util.telemetry import instrument
  from ..service import AbstractService
  from ..service import AuthedServiceContext
  from ..service import SyftError
  from ..service import service_method
  from ..user.user_roles import ADMIN_ROLE_LEVEL
  from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL
  from .utils import DEFAULT_WORKER_POOL_NAME
  from .utils import _get_healthcheck_based_on_status
  from .worker_pool import ContainerSpawnStatus
  from .worker_pool import SyftWorker
  from .worker_pool import WorkerHealth
  from .worker_pool import WorkerStatus
  from .worker_pool import _get_worker_container_status
  from .worker_stash import WorkerStash
label_desc: Use image node_id 1 for calling a global function with example usage: _check_and_update_status_for_worker(client, worker, worker_stash, credentials) and returns: unknown, worker_status