code: def create_deepspeed_config(
      args: argparse.Namespace,
      optimizer_config: optimizers.OptimizerConfig,
      optimizer_class: Type[torch.optim.Optimizer],
      optimizer_kwargs: Dict[str, Any],
  ) -> Dict[str, Any]:
      """
      Generates a DeepSpeed config dictionary from training arguments. See:
      https://www.deepspeed.ai/docs/config-json/
  
      :param args: Arguments as returned by argparse.
      :param optimizer_config: Optimizer config.
      :param optimizer_class: Optimizer class.
      :param optimizer_kwargs: Optimizer kwargs.
  
      :return: Dictionary of config options that can be used to initialize the
               DeepSpeed engine.
      """
  
      utils.check_condition(
          utils.using_deepspeed(),
          "Initialize DeepSpeed before generating the config",
      )
  
      ds_config = {
          "train_micro_batch_size_per_gpu": args.batch_size,
          "gradient_accumulation_steps": args.update_interval,
          "optimizer": {
              "type": optimizer_class.__name__,
              "params": optimizer_kwargs,
          },
          "zero_optimization": {
              "stage": 1,
          },
          "steps_per_print": args.update_interval
          * args.checkpoint_interval,
      }
  
      if args.deepspeed_fp16:
          utils.update_dict(
              ds_config,
              {
                  "fp16": {
                      "enabled": True,
                      "initial_scale_power": 18,
                  },
              },
          )
  
      if args.deepspeed_bf16:
          utils.update_dict(
              ds_config,
              {
                  "bf16": {
                      "enabled": True,
                  },
              },
          )
  
      if (
          optimizer_config.gradient_clipping_type
          != C.GRADIENT_CLIPPING_TYPE_NONE
      ):
          utils.update_dict(
              ds_config,
              {
                  "gradient_clipping": optimizer_config.gradient_clipping_threshold,
              },
          )
  
      return ds_config
  
imports: from .None import initial_setup
  import argparse
  import gc
  import logging
  import os
  import shutil
  import sys
  import tempfile
  from typing import Any, cast, Callable, Optional, Dict, List, Tuple, Type
  import torch
  import torch.distributed
  import torch.distributed.elastic.multiprocessing.errors
  from .None import arguments
  from .None import checkpoint_decoder
  from .None import constants
  from .None import convert_deepspeed
  from .None import data_io
  from .None import encoder
  from .None import layers
  from .None import loss
  from .None import lr_scheduler
  from .None import model
  from .None import optimizers
  from .None import training
  from .None import transformer
  from .None import utils
  from .None import vocab
  from .config import Config
  from .log import setup_main_logger
  from .utils import check_condition
label_desc: Use image node_id 15 for calling a global function with example usage: create_deepspeed_config(args, optimizer_config, optimizer_class, optimizer_kwargs) and returns: ds_config