code: def test_cancel_left_after_tail(client):
      batch = create_batch(client)
      head = batch.create_job(
          DOCKER_ROOT_IMAGE, command=["echo", "head"]
      )
      left = batch.create_job(
          DOCKER_ROOT_IMAGE,
          command=["/bin/sh", "-c", "while true; do sleep 86000; done"],
          parents=[head],
      )
      right = batch.create_job(
          DOCKER_ROOT_IMAGE, command=["echo", "right"], parents=[head]
      )
      tail = batch.create_job(
          DOCKER_ROOT_IMAGE,
          command=["echo", "tail"],
          parents=[left, right],
      )
      try:
          batch.submit()
          head.wait()
          right.wait()
      finally:
          batch.cancel()
      batch.wait()
      status = legacy_batch_status(batch)
      assert batch_status_job_counter(status, "Success") == 2, str(
          (status, batch.debug_info())
      )
      for node in [head, right]:
          status = node.status()
          assert status["state"] == "Success", str(
              (status, batch.debug_info())
          )
          assert node._get_exit_code(status, "main") == 0, str(
              (status, batch.debug_info())
          )
      for node in [left, tail]:
          node_status = node.status()
          assert node_status["state"] == "Cancelled", str(
              (node_status, batch.debug_info())
          )
  
imports: import asyncio
  import os
  import re
  import secrets
  import pytest
  from aiohttp import web
  from hailtop.batch_client import aioclient
  from hailtop.batch_client.client import BatchClient, Job
  from .utils import DOCKER_ROOT_IMAGE, batch_status_job_counter, create_batch, legacy_batch_status
label_desc: Use image node_id 6 for calling a global function with example usage: test_cancel_left_after_tail(client) without return types