code: def run(
      # Context object for subcommands
      ctx: typer.Context,
      # Config-based arguments.
      algo: str = cli.Algo,
      env: str = cli.Env,
      config: str = cli.Config,
      stop: str = cli.Stop,
      experiment_name: str = cli.ExperimentName,
      num_samples: int = cli.NumSamples,
      checkpoint_freq: int = cli.CheckpointFreq,
      checkpoint_at_end: bool = cli.CheckpointAtEnd,
      local_dir: str = cli.LocalDir,
      restore: str = cli.Restore,
      resources_per_trial: str = cli.ResourcesPerTrial,
      keep_checkpoints_num: int = cli.KeepCheckpointsNum,
      checkpoint_score_attr: str = cli.CheckpointScoreAttr,
      upload_dir: str = cli.UploadDir,
      # Additional config arguments used for overriding.
      v: bool = cli.V,
      vv: bool = cli.VV,
      framework: FrameworkEnum = cli.Framework,
      trace: bool = cli.Trace,
      # Ray cluster options.
      local_mode: bool = cli.LocalMode,
      ray_address: str = cli.RayAddress,
      ray_ui: bool = cli.RayUi,
      ray_num_cpus: int = cli.RayNumCpus,
      ray_num_gpus: int = cli.RayNumGpus,
      ray_num_nodes: int = cli.RayNumNodes,
      ray_object_store_memory: int = cli.RayObjectStoreMemory,
      # Ray scheduling options.
      resume: bool = cli.Resume,
      scheduler: str = cli.Scheduler,
      scheduler_config: str = cli.SchedulerConfig,
  ):
      """Train a reinforcement learning agent from command line options.
      The options --env and --algo are required to run this command.
  
      Training example via RLlib CLI:\n
          rllib train --algo DQN --env CartPole-v1\n\n
      """
  
      # If no subcommand is specified, simply run the following lines as the
      # "rllib train" main command.
      if ctx.invoked_subcommand is None:
          # we only check for backends when actually running the command. otherwise the
          # start-up time is too slow.
          import_backends()
  
          framework = framework.value if framework else None
  
          config = json.loads(config)
          resources_per_trial = json_to_resources(resources_per_trial)
  
          # Load a single experiment from configuration
          experiments = {
              experiment_name: {  # i.e. log to ~/ray_results/default
                  "run": algo,
                  "checkpoint_config": {
                      "checkpoint_frequency": checkpoint_freq,
                      "checkpoint_at_end": checkpoint_at_end,
                      "num_to_keep": keep_checkpoints_num,
                      "checkpoint_score_attribute": checkpoint_score_attr,
                  },
                  "local_dir": local_dir,
                  "resources_per_trial": (
                      resources_per_trial
                      and resources_to_json(resources_per_trial)
                  ),
                  "stop": json.loads(stop),
                  "config": dict(config, env=env),
                  "restore": restore,
                  "num_samples": num_samples,
                  "sync_config": {
                      "upload_dir": upload_dir,
                  },
              }
          }
  
          run_rllib_experiments(
              experiments=experiments,
              v=v,
              vv=vv,
              framework=framework,
              trace=trace,
              ray_num_nodes=ray_num_nodes,
              ray_num_cpus=ray_num_cpus,
              ray_num_gpus=ray_num_gpus,
              ray_object_store_memory=ray_object_store_memory,
              ray_ui=ray_ui,
              ray_address=ray_address,
              local_mode=local_mode,
              resume=resume,
              scheduler=scheduler,
              scheduler_config=scheduler_config,
              algo=algo,
          )
  
imports: import importlib
  import json
  import os
  from pathlib import Path
  import re
  import sys
  import typer
  from typing import Optional
  import uuid
  import yaml
  import ray
  from ray.air.integrations.wandb import WandbLoggerCallback
  from ray.tune.resources import resources_to_json, json_to_resources
  from ray.tune.tune import run_experiments
  from ray.tune.schedulers import create_scheduler
  from ray.rllib.utils.framework import try_import_tf, try_import_torch
  from ray.rllib.common import CLIArguments
  from ray.rllib.common import FrameworkEnum, SupportedFileType
  from ray.rllib.common import download_example_file, get_file_type
label_desc: Use image node_id 5 for calling a global function with example usage: run(ctx, algo, env, config, stop, experiment_name, num_samples, checkpoint_freq, checkpoint_at_end, local_dir, restore, resources_per_trial, keep_checkpoints_num, checkpoint_score_attr, upload_dir, v, vv, framework, trace, local_mode, ray_address, ray_ui, ray_num_cpus, ray_num_gpus, ray_num_nodes, ray_object_store_memory, resume, scheduler, scheduler_config) without return types