code: def get_launcher(distributed=False, use_accelerate=False):
      # 1. explicitly set --num_nodes=1 just in case these tests end up run on a multi-node setup
      # - it won't be able to handle that
      # 2. for now testing with just 2 gpus max (since some quality tests may give different
      # results with mode gpus because we use very little data)
      num_gpus = (
          min(2, backend_device_count(torch_device))
          if distributed
          else 1
      )
      master_port = get_master_port(real_launcher=True)
      if use_accelerate:
          return f"""accelerate launch
          --num_processes {num_gpus}
          --main_process_port {master_port}
          --use_fsdp
          --fsdp_auto_wrap_policy TRANSFORMER_BASED_WRAP
          --fsdp_state_dict_type SHARDED_STATE_DICT
          --fsdp_transformer_layer_cls_to_wrap BertLayer""".split()
      return f"torchrun --nnodes 1 --nproc-per-node {num_gpus} --master-port {master_port}".split()
  
imports: import itertools
  import os
  import unittest
  from functools import partial
  from parameterized import parameterized
  import tests.trainer.test_trainer
  from tests.trainer.test_trainer import TrainerIntegrationCommon
  from transformers import is_torch_available
  from transformers.testing_utils import TestCasePlus, backend_device_count, execute_subprocess_async, mockenv_context, require_accelerate, require_fsdp, require_torch_accelerator, require_torch_multi_accelerator, slow, torch_device
  from transformers.trainer_callback import TrainerState
  from transformers.trainer_utils import FSDPOption, set_seed
  from transformers.utils import is_accelerate_available, is_torch_bf16_available_on_device
label_desc: Use image node_id 2 for calling a global function with example usage: get_launcher(distributed, use_accelerate) and returns: str, num_gpus, str, master_port, str, num_gpus, str, master_port, str