code: def test_compute_success():
      """Task.compute returns (True, (task, batch)) on success."""
  
      def _42():
          return Batch(torch.tensor(42))
  
      with spawn_workers([torch.device("cpu")]) as (
          in_queues,
          out_queues,
      ):
          t = Task(CPUStream, compute=_42, finalize=None)
          in_queues[0].put(t)
          ok, (task, batch) = out_queues[0].get()
  
          assert ok
          assert task is t
          assert isinstance(batch, Batch)
          assert batch[0].item() == 42
  
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 2 for calling a global function with example usage: test_compute_success() and returns: Batch