code: def pg_launcher(pre_created_pgs, num_pgs_to_create):
      pgs = []
      pgs += pre_created_pgs
      for i in range(num_pgs_to_create):
          pgs.append(placement_group(BUNDLES, strategy="STRICT_SPREAD"))
  
      pgs_removed = []
      pgs_unremoved = []
      # Randomly choose placement groups to remove.
      for pg in pgs:
          if random() < 0.5:
              pgs_removed.append(pg)
          else:
              pgs_unremoved.append(pg)
  
      tasks = []
      max_actor_cnt = 5
      actor_cnt = 0
      actors = []
      # Randomly schedule tasks or actors on placement groups that
      # are not removed.
      for pg in pgs_unremoved:
          # TODO(sang): Comment in this line causes GCS actor management
          # failure. We need to fix it.
          if random() < 0.5:
              tasks.append(
                  mock_task.options(
                      scheduling_strategy=PlacementGroupSchedulingStrategy(
                          placement_group=pg
                      )
                  ).remote()
              )
          else:
              if actor_cnt < max_actor_cnt:
                  actors.append(
                      MockActor.options(
                          scheduling_strategy=PlacementGroupSchedulingStrategy(
                              placement_group=pg
                          )
                      ).remote()
                  )
                  actor_cnt += 1
  
      # Remove the rest of placement groups.
      for pg in pgs_removed:
          remove_placement_group(pg)
  
      ray.get([pg.ready() for pg in pgs_unremoved])
      ray.get(tasks)
      ray.get([actor.ping.remote() for actor in actors])
      # Since placement groups are scheduled, remove them.
      for pg in pgs_unremoved:
          remove_placement_group(pg)
  
file_path: ray/release/nightly_tests/stress_tests/test_placement_group.py
imports: import time
  from time import perf_counter
  from random import random
  import json
  import logging
  import os
  import ray
  from ray.util.placement_group import placement_group, remove_placement_group
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 2 for calling a global function with example usage: pg_launcher(pre_created_pgs, num_pgs_to_create) without return types