class_docstr: Targeted at testing functions of built-in tuners, including
      - [ ] load_checkpoint
      - [ ] save_checkpoint
      - [X] update_search_space
      - [X] generate_multiple_parameters
      - [X] import_data
      - [ ] trial_end
      - [x] receive_trial_result
class_docstr_tok: ["Targeted","at","testing","functions","of","built-in","tuners",",","including","-","[","]","load_checkpoint","-","[","]","save_checkpoint","-","[","X","]","update_search_space","-","[","X","]","generate_multiple_parameters","-","[","X","]","import_data","-","[","]","trial_end","-","[","x","]","receive_trial_result"]
docstr: test1: import data with complete epoch
  test2: import data with incomplete epoch
docstr_tok: ["test1",":","import","data","with","complete","epoch","test2",":","import","data","with","incomplete","epoch"]
code: def import_data_test_for_pbt(self):
      """
      test1: import data with complete epoch
      test2: import data with incomplete epoch
      """
      search_space = {
          "choice_str": {
              "_type": "choice",
              "_value": [
                  "cat",
                  "dog",
                  "elephant",
                  "cow",
                  "sheep",
                  "panda",
              ],
          }
      }
      all_checkpoint_dir = os.path.expanduser("~/nni/checkpoint/test/")
      population_size = 4
      # ===import data at the beginning===
      tuner = PBTTuner(
          all_checkpoint_dir=all_checkpoint_dir,
          population_size=population_size,
      )
      self.assertIsInstance(tuner, Tuner)
      tuner.update_search_space(search_space)
      save_dirs = [
          os.path.join(all_checkpoint_dir, str(i), str(0))
          for i in range(population_size)
      ]
      # create save checkpoint directory
      for save_dir in save_dirs:
          os.makedirs(save_dir, exist_ok=True)
      # for simplicity, omit "load_checkpoint_dir"
      data = [
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[0],
              },
              "value": 1.1,
          },
          {
              "parameter": {
                  "choice_str": "dog",
                  "save_checkpoint_dir": save_dirs[1],
              },
              "value": {"default": 1.2, "tmp": 2},
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[2],
              },
              "value": 11,
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[3],
              },
              "value": 7,
          },
      ]
      epoch = tuner.import_data(data)
      self.assertEqual(epoch, 1)
      logger.info("Imported data successfully at the beginning")
      shutil.rmtree(all_checkpoint_dir)
      # ===import another data at the beginning, test the case when there is an incompleted epoch===
      tuner = PBTTuner(
          all_checkpoint_dir=all_checkpoint_dir,
          population_size=population_size,
      )
      self.assertIsInstance(tuner, Tuner)
      tuner.update_search_space(search_space)
      for i in range(population_size - 1):
          save_dirs.append(
              os.path.join(all_checkpoint_dir, str(i), str(1))
          )
      for save_dir in save_dirs:
          os.makedirs(save_dir, exist_ok=True)
      data = [
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[0],
              },
              "value": 1.1,
          },
          {
              "parameter": {
                  "choice_str": "dog",
                  "save_checkpoint_dir": save_dirs[1],
              },
              "value": {"default": 1.2, "tmp": 2},
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[2],
              },
              "value": 11,
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[3],
              },
              "value": 7,
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[4],
              },
              "value": 1.1,
          },
          {
              "parameter": {
                  "choice_str": "dog",
                  "save_checkpoint_dir": save_dirs[5],
              },
              "value": {"default": 1.2, "tmp": 2},
          },
          {
              "parameter": {
                  "choice_str": "cat",
                  "save_checkpoint_dir": save_dirs[6],
              },
              "value": 11,
          },
      ]
      epoch = tuner.import_data(data)
      self.assertEqual(epoch, 1)
      logger.info(
          "Imported data successfully at the beginning with incomplete epoch"
      )
      shutil.rmtree(all_checkpoint_dir)
  
imports: import glob
  import json
  import logging
  import os
  import random
  import shutil
  import sys
  from collections import deque
  from unittest import TestCase, main
  from nni.algorithms.hpo.batch_tuner import BatchTuner
  from nni.algorithms.hpo.dngo_tuner import DNGOTuner
  from nni.algorithms.hpo.evolution_tuner import EvolutionTuner
  from nni.algorithms.hpo.gp_tuner import GPTuner
  from nni.algorithms.hpo.gridsearch_tuner import GridSearchTuner
  from nni.algorithms.hpo.hyperopt_tuner import HyperoptTuner
  from nni.algorithms.hpo.metis_tuner import MetisTuner
  from nni.algorithms.hpo.pbt_tuner import PBTTuner
  from nni.algorithms.hpo.random_tuner import RandomTuner
  from nni.algorithms.hpo.regularized_evolution_tuner import RegularizedEvolutionTuner
  from nni.algorithms.hpo.tpe_tuner import TpeTuner
  from nni.runtime.msg_dispatcher import _pack_parameter, MsgDispatcher
  from nni.tuner import Tuner
label_desc: Use image node_id 9 for calling the BuiltinTunersTestCase obj's underlying member method code with example usage: obj.import_data_test_for_pbt() without return types