code: def _get_scheduler(
      hyperparameter_tune_kwargs: dict,
      supported_schedulers: Optional[List[str]] = None,
  ):
      """Initialize scheduler object"""
      scheduler = hyperparameter_tune_kwargs.get("scheduler")
      user_init_args = hyperparameter_tune_kwargs.get(
          "scheduler_init_args", dict()
      )
      if isinstance(scheduler, str):
          assert (
              scheduler in SCHEDULER_PRESETS
          ), f"{scheduler} is not a valid option. Options are {SCHEDULER_PRESETS.keys()}"
          # Check supported schedulers for str input
          if supported_schedulers is not None:
              if scheduler not in supported_schedulers:
                  logger.warning(
                      f"{scheduler} is not supported yet. Using it might behave unexpected. Supported options are {supported_schedulers}"
                  )
          scheduler = SchedulerFactory.get_scheduler(
              scheduler_name=scheduler,
              user_init_args=user_init_args,
          )
      assert (
          isinstance(scheduler, TrialScheduler)
          and scheduler.__class__ in SCHEDULER_PRESETS.values()
      )
      # Check supported schedulers for obj input
      if supported_schedulers is not None:
          supported_schedulers_cls = [
              SCHEDULER_PRESETS[scheduler]
              for scheduler in supported_schedulers
          ]
          if scheduler.__class__ not in supported_schedulers_cls:
              logger.warning(
                  f"{scheduler.__class__} is not supported yet. Using it might behave unexpected. Supported options are {supported_schedulers_cls}"
              )
      return scheduler
  
imports: import logging
  import os
  import shutil
  from autogluon.common import space
  from autogluon.common.utils.distribute_utils import DistributedContext
  from autogluon.common.utils.try_import import try_import_ray
  from abc import ABC, abstractmethod
  from typing import Callable, List, Optional, Union
  import ray
  from ray import air, tune
  from ray.tune import ExperimentAnalysis, PlacementGroupFactory
  from ray.tune.schedulers import TrialScheduler
  from ray.tune.search import SearchAlgorithm, Searcher
  from ray.tune.search.sample import Domain
  from autogluon.common.utils.resource_utils import ResourceManager
  from ..ray.resources_calculator import ResourceCalculator, ResourceCalculatorFactory
  from .constants import MAX, MIN
  from .exceptions import EmptySearchSpace
  from .ray_tune_constants import SCHEDULER_PRESETS, SEARCHER_PRESETS
  from .ray_tune_scheduler_factory import SchedulerFactory
  from .ray_tune_searcher_factory import SearcherFactory
  from .space_converter import RaySpaceConverterFactory
label_desc: Use image node_id 9 for calling a global function with example usage: _get_scheduler(hyperparameter_tune_kwargs, supported_schedulers) and returns: scheduler