code: def test_single_worker_failure(ray_start_4_cpus):
      """Tests if training fails upon any worker failure."""
  
      def single_worker_fail():
          if train.get_context().get_world_rank() == 0:
              raise RuntimeError
          else:
              time.sleep(1000000)
  
      scaling_config = ScalingConfig(num_workers=2)
      trainer = TorchTrainer(
          train_loop_per_worker=single_worker_fail,
          scaling_config=scaling_config,
      )
      with pytest.raises(TrainingFailedError) as exc_info:
          trainer.fit()
      assert isinstance(exc_info.value.__cause__, RuntimeError)
  
imports: import contextlib
  import os
  import tempfile
  import time
  import uuid
  from unittest.mock import patch
  import pytest
  import torch
  import ray
  import ray.train
  from ray.cluster_utils import Cluster
  from ray.train import Checkpoint, RunConfig, ScalingConfig
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.train.torch import TorchCheckpoint, TorchConfig, TorchPredictor, TorchTrainer
  from ray.train.trainer import TrainingFailedError
label_desc: Use image node_id 9 for calling a global function with example usage: test_single_worker_failure(ray_start_4_cpus) without return types