class_docstr: Testing non-Trainer DeepSpeed integration
class_docstr_tok: ["Testing","non-Trainer","DeepSpeed","integration"]
code: def test_init_zero3_fp16(self):
      # test that zero.Init() works correctly under zero3/fp16
      ds_config = {
          "train_batch_size": 1,
          "zero_optimization": {
              "stage": 3,
          },
      }
  
      dschf = HfDeepSpeedConfig(ds_config)
  
      self.assertTrue(dschf.is_zero3())
      self.assertTrue(is_deepspeed_zero3_enabled())
  
      with LoggingLevel(logging.INFO):
          with mockenv_context(**self.dist_env_1_gpu):
              logger = logging.get_logger("transformers.modeling_utils")
              with CaptureLogger(logger) as cl:
                  AutoModel.from_pretrained(T5_TINY)
      self.assertIn("Detected DeepSpeed ZeRO-3", cl.out)
  
      # now remove zero optimization
      del ds_config["zero_optimization"]
      dschf = HfDeepSpeedConfig(ds_config)
  
      self.assertFalse(dschf.is_zero3())
      self.assertFalse(is_deepspeed_zero3_enabled())
  
      with LoggingLevel(logging.INFO):
          with mockenv_context(**self.dist_env_1_gpu):
              logger = logging.get_logger("transformers.modeling_utils")
              with CaptureLogger(logger) as cl:
                  AutoModel.from_pretrained(T5_TINY)
      self.assertNotIn("Detected DeepSpeed ZeRO-3", cl.out)
  
imports: import dataclasses
  import io
  import itertools
  import json
  import os
  import unittest
  from copy import deepcopy
  import datasets
  from parameterized import parameterized
  from tests.trainer.test_trainer import TrainerIntegrationCommon
  from transformers import AutoModel, TrainingArguments, is_torch_available, logging
  from transformers.deepspeed import HfDeepSpeedConfig, is_deepspeed_available, unset_hf_deepspeed_config
  from transformers.testing_utils import CaptureLogger, CaptureStd, CaptureStderr, LoggingLevel, TestCasePlus, execute_subprocess_async, get_gpu_count, mockenv_context, require_deepspeed, require_optuna, require_torch_gpu, require_torch_multi_gpu, slow
  from transformers.trainer_utils import get_last_checkpoint, set_seed
  from transformers.utils import WEIGHTS_NAME, is_torch_bf16_gpu_available
label_desc: Use image node_id 3 for calling the CoreIntegrationDeepSpeed obj's underlying member method code with example usage: obj.test_init_zero3_fp16() without return types