code: def test_slurm_job_array_mocked(
      use_batch_api: bool, tmp_path: Path
  ) -> None:
      n = 5
      with mocked_slurm() as mock:
          executor = slurm.SlurmExecutor(folder=tmp_path)
          executor.update_parameters(array_parallelism=3)
          data1, data2 = range(n), range(10, 10 + n)
  
          def add(x: int, y: int) -> int:
              assert x in data1
              assert y in data2
              return x + y
  
          jobs: tp.List[Job[int]] = []
          if use_batch_api:
              with executor.batch():
                  for d1, d2 in zip(data1, data2):
                      jobs.append(executor.submit(add, d1, d2))
          else:
              jobs = executor.map_array(add, data1, data2)
          array_id = jobs[0].job_id.split("_")[0]
          assert [f"{array_id}_{a}" for a in range(n)] == [
              j.job_id for j in jobs
          ]
  
          for job in jobs:
              assert job.state == "RUNNING"
              with mock.job_context(job.job_id):
                  submission.process_job(job.paths.folder)
          # trying a slurm specific method
          jobs[0]._interrupt(timeout=True)  # type: ignore
          assert list(map(add, data1, data2)) == [
              j.result() for j in jobs
          ]
          # check submission file
          sbatch = Job(
              tmp_path, job_id=array_id
          ).paths.submission_file.read_text()
          array_line = [
              l.strip() for l in sbatch.splitlines() if "--array" in l
          ]
          assert array_line == ["#SBATCH --array=0-4%3"]
  
imports: import contextlib
  import os
  import signal
  import subprocess
  import typing
  from pathlib import Path
  from unittest.mock import patch
  import pytest
  import submitit
  from ..None import helpers
  from ..core import job_environment, submission, test_core, utils
  from ..core.core import Job
  from .None import slurm
label_desc: Use image node_id 6 for calling a global function with example usage: test_slurm_job_array_mocked(use_batch_api, tmp_path) and returns: unknown