code: def _make_sbatch_string(
      command: str,
      folder: tp.Union[str, Path],
      job_name: str = "submitit",
      partition: tp.Optional[str] = None,
      time: int = 5,
      nodes: int = 1,
      ntasks_per_node: tp.Optional[int] = None,
      cpus_per_task: tp.Optional[int] = None,
      cpus_per_gpu: tp.Optional[int] = None,
      num_gpus: tp.Optional[int] = None,  # legacy
      gpus_per_node: tp.Optional[int] = None,
      gpus_per_task: tp.Optional[int] = None,
      qos: tp.Optional[str] = None,  # quality of service
      setup: tp.Optional[tp.List[str]] = None,
      mem: tp.Optional[str] = None,
      mem_per_gpu: tp.Optional[str] = None,
      mem_per_cpu: tp.Optional[str] = None,
      signal_delay_s: int = 90,
      comment: tp.Optional[str] = None,
      constraint: tp.Optional[str] = None,
      exclude: tp.Optional[str] = None,
      account: tp.Optional[str] = None,
      gres: tp.Optional[str] = None,
      mail_type: tp.Optional[str] = None,
      mail_user: tp.Optional[str] = None,
      nodelist: tp.Optional[str] = None,
      dependency: tp.Optional[str] = None,
      exclusive: tp.Optional[tp.Union[bool, str]] = None,
      array_parallelism: int = 256,
      wckey: str = "submitit",
      stderr_to_stdout: bool = False,
      map_count: tp.Optional[int] = None,  # used internally
      additional_parameters: tp.Optional[tp.Dict[str, tp.Any]] = None,
      srun_args: tp.Optional[tp.Iterable[str]] = None,
      use_srun: bool = True,
  ) -> str:
      """Creates the content of an sbatch file with provided parameters
  
      Parameters
      ----------
      See slurm sbatch documentation for most parameters:
      https://slurm.schedmd.com/sbatch.html
  
      Below are the parameters that differ from slurm documentation:
  
      folder: str/Path
          folder where print logs and error logs will be written
      signal_delay_s: int
          delay between the kill signal and the actual kill of the slurm job.
      setup: list
          a list of command to run in sbatch before running srun
      map_size: int
          number of simultaneous map/array jobs allowed
      additional_parameters: dict
          Forces any parameter to a given value in sbatch. This can be useful
          to add parameters which are not currently available in submitit.
          Eg: {"mail-user": "blublu@fb.com", "mail-type": "BEGIN"}
      srun_args: List[str]
          Add each argument in the list to the srun call
  
      Raises
      ------
      ValueError
          In case an erroneous keyword argument is added, a list of all eligible parameters
          is printed, with their default values
      """
      nonslurm = [
          "nonslurm",
          "folder",
          "command",
          "map_count",
          "array_parallelism",
          "additional_parameters",
          "setup",
          "signal_delay_s",
          "stderr_to_stdout",
          "srun_args",
          "use_srun",  # if False, un python directly in sbatch instead of through srun
      ]
      parameters = {
          k: v
          for k, v in locals().items()
          if v is not None and k not in nonslurm
      }
      # rename and reformat parameters
      parameters[
          "signal"
      ] = f"{SlurmJobEnvironment.USR_SIG}@{signal_delay_s}"
      if num_gpus is not None:
          warnings.warn(
              '"num_gpus" is deprecated, please use "gpus_per_node" instead (overwritting with num_gpus)'
          )
          parameters["gpus_per_node"] = parameters.pop("num_gpus", 0)
      if (
          "cpus_per_gpu" in parameters
          and "gpus_per_task" not in parameters
      ):
          warnings.warn(
              '"cpus_per_gpu" requires to set "gpus_per_task" to work (and not "gpus_per_node")'
          )
      # add necessary parameters
      paths = utils.JobPaths(folder=folder)
      stdout = str(paths.stdout)
      stderr = str(paths.stderr)
      # Job arrays will write files in the form  <ARRAY_ID>_<ARRAY_TASK_ID>_<TASK_ID>
      if map_count is not None:
          assert isinstance(map_count, int) and map_count
          parameters[
              "array"
          ] = f"0-{map_count - 1}%{min(map_count, array_parallelism)}"
          stdout = stdout.replace("%j", "%A_%a")
          stderr = stderr.replace("%j", "%A_%a")
      parameters["output"] = stdout.replace("%t", "0")
      if not stderr_to_stdout:
          parameters["error"] = stderr.replace("%t", "0")
      parameters["open-mode"] = "append"
      if additional_parameters is not None:
          parameters.update(additional_parameters)
      # now create
      lines = ["#!/bin/bash", "", "# Parameters"]
      for k in sorted(parameters):
          lines.append(_as_sbatch_flag(k, parameters[k]))
      # environment setup:
      if setup is not None:
          lines += ["", "# setup"] + setup
      # commandline (this will run the function and args specified in the file provided as argument)
      # We pass --output and --error here, because the SBATCH command doesn't work as expected with a filename pattern
  
      if use_srun:
          # using srun has been the only option historically,
          # but it's not clear anymore if it is necessary, and using it prevents
          # jobs from scheduling other jobs
          stderr_flags = [] if stderr_to_stdout else ["--error", stderr]
          if srun_args is None:
              srun_args = []
          srun_cmd = _shlex_join(
              [
                  "srun",
                  "--unbuffered",
                  "--output",
                  stdout,
                  *stderr_flags,
                  *srun_args,
              ]
          )
          command = " ".join((srun_cmd, command))
  
      lines += [
          "",
          "# command",
          "export SUBMITIT_EXECUTOR=slurm",
          # The input "command" is supposed to be a valid shell command
          command,
          "",
      ]
      return "\n".join(lines)
  
imports: import functools
  import inspect
  import os
  import re
  import shlex
  import shutil
  import subprocess
  import sys
  import typing
  import uuid
  import warnings
  from pathlib import Path
  from ..core import core, job_environment, logger, utils
label_desc: Use image node_id 6 for calling a global function with example usage: _make_sbatch_string(command, folder, job_name, partition, time, nodes, ntasks_per_node, cpus_per_task, cpus_per_gpu, num_gpus, gpus_per_node, gpus_per_task, qos, setup, mem, mem_per_gpu, mem_per_cpu, signal_delay_s, comment, constraint, exclude, account, gres, mail_type, mail_user, nodelist, dependency, exclusive, array_parallelism, wckey, stderr_to_stdout, map_count, additional_parameters, srun_args, use_srun) and returns: str