code: def test_nonserializable_train_function(ray_start_4_cpus):
      import threading
  
      lock = threading.Lock()
  
      def train_func():
          print(lock)
  
      trainer = TorchTrainer(train_func)
      # Check that the `inspect_serializability` trace was printed
      with pytest.raises(
          TypeError, match=r".*was found to be non-serializable.*"
      ):
          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 14 for calling a global function with example usage: test_nonserializable_train_function(ray_start_4_cpus) without return types