code: def test_torch_session_errors(ray_start_4_cpus):
      """Test fail-fast behavior when reporting dicts with Torch tensors"""
  
      def train_func():
          model = torch.nn.Linear(1, 1).state_dict()
          with pytest.raises(ValueError):
              train.report(model)
  
      scaling_config = ScalingConfig(num_workers=2)
      trainer = TorchTrainer(
          train_loop_per_worker=train_func,
          scaling_config=scaling_config,
      )
      trainer.fit()
  
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 8 for calling a global function with example usage: test_torch_session_errors(ray_start_4_cpus) without return types