code: def test_compute_multithreading():
      """Task.compute should be executed on multiple threads."""
      thread_ids = set()
  
      def log_thread_id():
          thread_id = threading.current_thread().ident
          thread_ids.add(thread_id)
          return Batch(())
  
      with spawn_workers([fake_device() for _ in range(2)]) as (
          in_queues,
          out_queues,
      ):
          for i in range(2):
              t = Task(CPUStream, compute=log_thread_id, finalize=None)
              in_queues[i].put(t)
          for i in range(2):
              out_queues[i].get()
  
      assert len(thread_ids) == 2
  
file_path: pytorch/test/distributed/pipeline/sync/test_worker.py
imports: import threading
  import pytest
  import torch
  from torch.distributed.pipeline.sync.microbatch import Batch
  from torch.distributed.pipeline.sync.stream import CPUStream
  from torch.distributed.pipeline.sync.worker import Task, spawn_workers
  from torch.testing._internal.common_utils import run_tests
label_desc: Use image node_id 1 for calling a global function with example usage: test_compute_multithreading() and returns: Batch