code: def get_valid_gpus(
      batch_size, micro_batches, min_valid_gpus, max_valid_gpus
  ):
      valid_gpus = []
      for micro_batch in micro_batches:
          if batch_size % micro_batch == 0:
              max_gpus = batch_size // micro_batch
              if min_valid_gpus <= max_gpus <= max_valid_gpus:
                  valid_gpus.append(max_gpus)
  
              # find all factors less than max_gpus / 2
              for i in range(1, max_gpus // 2 + 1):
                  if i > max_valid_gpus:
                      break
                  if i < min_valid_gpus:
                      continue
                  if max_gpus % i == 0:
                      valid_gpus.append(i)
      valid_gpus = set(valid_gpus)
      valid_gpus = sorted(list(valid_gpus))
      return valid_gpus
  
file_path: DeepSpeed/deepspeed/elasticity/elasticity.py
imports: import os
  import json
  import numpy
  import math
  from packaging import version
  from .config import ElasticityConfig, ElasticityConfigError, ElasticityError, ElasticityIncompatibleWorldSize
  from .constants import ELASTICITY, ENABLED, ENABLED_DEFAULT, LATEST_ELASTICITY_VERSION, MINIMUM_DEEPSPEED_VERSION, DEEPSPEED_ELASTICITY_CONFIG
  from ..git_version_info import version
  from ..utils import logger
label_desc: Use image node_id 2 for calling a global function with example usage: get_valid_gpus(batch_size, micro_batches, min_valid_gpus, max_valid_gpus) and returns: valid_gpus