code: def test_restore_invalid_checkpoint(
      self, tmp_path: pathlib.Path
  ) -> None:
      # Build, train, and save a checkpoint with the normal hyperparameters.
      checkpoint_dir = str(tmp_path.joinpath("checkpoint"))
      latest_checkpoint = None
      steps_completed = 0
  
      def make_workloads_1() -> workload.Stream:
          trainer = utils.TrainAndValidate()
          yield from trainer.send(
              steps=1,
              validation_freq=1,
              train_batch_calls=self.data_parallel_only_auto_train_batch_calls,
          )
          interceptor = workload.WorkloadResponseInterceptor()
          yield from interceptor.send(workload.checkpoint_workload())
          nonlocal latest_checkpoint, steps_completed
          latest_checkpoint = interceptor.metrics_result()["uuid"]
          steps_completed = trainer.get_steps_completed()
  
      controller1 = (
          utils.make_trial_controller_from_trial_implementation(
              trial_class=deepspeed_linear_model.LinearDeepSpeedTrial,
              hparams=self.hparams,
              workloads=make_workloads_1(),
              trial_seed=self.trial_seed,
              checkpoint_dir=checkpoint_dir,
              expose_gpus=True,
          )
      )
      controller1.run()
  
      # Verify that an invalid architecture fails to load from the checkpoint.
      def make_workloads_2() -> workload.Stream:
          trainer = utils.TrainAndValidate()
          yield from trainer.send(
              steps=1,
              validation_freq=1,
              train_batch_calls=self.data_parallel_only_auto_train_batch_calls,
          )
  
      with pytest.raises(
          AssertionError, match="Failed to load deepspeed checkpoint."
      ):
          controller2 = utils.make_trial_controller_from_trial_implementation(
              trial_class=deepspeed_linear_model.LinearTwoEngineTrial,
              hparams=self.hparams,
              workloads=make_workloads_2(),
              trial_seed=self.trial_seed,
              checkpoint_dir=checkpoint_dir,
              latest_checkpoint=latest_checkpoint,
              steps_completed=steps_completed,
              expose_gpus=True,
          )
          controller2.run()
  
imports: import copy
  import json
  import os
  import pathlib
  from typing import Any, Dict, Iterator, Optional
  import pytest
  import torch
  from deepspeed.runtime import config_utils
  import determined
  import determined.pytorch.deepspeed
  from determined import workload
  from tests.experiment import utils
  from tests.experiment.fixtures import deepspeed_linear_model
label_desc: Use image node_id 20 for calling the TestDeepSpeedTrial obj's underlying member method code with example usage: obj.test_restore_invalid_checkpoint(tmp_path) without return types