code: def test_error_is_throw_when_cuda_device_is_not_available(self):
      params = Params(
          {
              "model": {
                  "type": "simple_tagger",
                  "text_field_embedder": {
                      "tokens": {
                          "type": "embedding",
                          "embedding_dim": 5,
                      }
                  },
                  "encoder": {
                      "type": "lstm",
                      "input_size": 5,
                      "hidden_size": 7,
                      "num_layers": 2,
                  },
              },
              "dataset_reader": {"type": "sequence_tagging"},
              "train_data_path": "tests/fixtures/data/sequence_tagging.tsv",
              "validation_data_path": "tests/fixtures/data/sequence_tagging.tsv",
              "iterator": {"type": "basic", "batch_size": 2},
              "trainer": {
                  "num_epochs": 2,
                  "cuda_device": torch.cuda.device_count(),
                  "optimizer": "adam",
              },
          }
      )
  
      with pytest.raises(
          ConfigurationError,
          message="Experiment specified a GPU but none is available;"
          " if you want to run on CPU use the override"
          " 'trainer.cuda_device=-1' in the json config file.",
      ):
          train_model(
              params,
              serialization_dir=os.path.join(
                  self.TEST_DIR, "test_train_model"
              ),
          )
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import argparse
  import os
  import shutil
  import re
  import pytest
  import torch
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.commands.train import Train, train_model, train_model_from_args
  from allennlp.data import DatasetReader, Instance
  from io import open
label_desc: Use image node_id 2 for calling the TestTrain obj's underlying member method code with example usage: obj.test_error_is_throw_when_cuda_device_is_not_available() without return types