code: def testPointsToEvaluateBasicVariantAdvanced(self):
      config = {
          "grid_1": tune.grid_search(["a", "b", "c", "d"]),
          "grid_2": tune.grid_search(["x", "y", "z"]),
          "nested": {
              "random": tune.uniform(2.0, 10.0),
              "dependent": tune.sample_from(
                  lambda spec: -1.0 * spec.config.nested.random
              ),
          },
      }
  
      points = [
          {"grid_1": "b"},
          {"grid_2": "z"},
          {"grid_1": "a", "grid_2": "y"},
          {"nested": {"random": 8.0}},
      ]
  
      from ray.tune.search.basic_variant import BasicVariantGenerator
  
      # grid_1 * grid_2 are 3 * 4 = 12 variants per complete grid search
      # However if one grid var is set by preset variables, that run
      # is excluded from grid search.
  
      # Point 1 overwrites grid_1, so the first trial only grid searches
      # over grid_2 (3 trials).
      # The remaining 5 trials search over the whole space (5 * 12 trials)
      searcher = BasicVariantGenerator(points_to_evaluate=[points[0]])
      exp = Experiment(
          run=_mock_objective, name="test", config=config, num_samples=6
      )
      searcher.add_configurations(exp)
      self.assertEqual(searcher.total_samples, 1 * 3 + 5 * 12)
  
      # Point 2 overwrites grid_2, so the first trial only grid searches
      # over grid_1 (4 trials).
      # The remaining 5 trials search over the whole space (5 * 12 trials)
      searcher = BasicVariantGenerator(points_to_evaluate=[points[1]])
      exp = Experiment(
          run=_mock_objective, name="test", config=config, num_samples=6
      )
      searcher.add_configurations(exp)
      self.assertEqual(searcher.total_samples, 1 * 4 + 5 * 12)
  
      # Point 3 overwrites grid_1 and grid_2, so the first trial does not
      # grid search.
      # The remaining 5 trials search over the whole space (5 * 12 trials)
      searcher = BasicVariantGenerator(points_to_evaluate=[points[2]])
      exp = Experiment(
          run=_mock_objective, name="test", config=config, num_samples=6
      )
      searcher.add_configurations(exp)
      self.assertEqual(searcher.total_samples, 1 + 5 * 12)
  
      # When initialized with all points, the first three trials are
      # defined by the logic above. Only 3 trials are grid searched
      # compeletely.
      searcher = BasicVariantGenerator(points_to_evaluate=points)
      exp = Experiment(
          run=_mock_objective, name="test", config=config, num_samples=6
      )
      searcher.add_configurations(exp)
      self.assertEqual(
          searcher.total_samples, 1 * 3 + 1 * 4 + 1 + 3 * 12
      )
  
      # Run this and confirm results
      analysis = tune.run(exp, search_alg=searcher)
      configs = [trial.config for trial in analysis.trials]
  
      self.assertEqual(len(configs), searcher.total_samples)
      self.assertTrue(
          all(config["grid_1"] == "b" for config in configs[0:3])
      )
      self.assertTrue(
          all(config["grid_2"] == "z" for config in configs[3:7])
      )
      self.assertTrue(
          configs[7]["grid_1"] == "a" and configs[7]["grid_2"] == "y"
      )
      self.assertTrue(configs[8]["nested"]["random"] == 8.0)
      self.assertTrue(configs[8]["nested"]["dependent"] == -8.0)
  
imports: from collections import defaultdict
  from unittest.mock import patch
  import numpy
  import unittest
  import ray
  import ray.tune.search.sample
  from ray import train, tune
  from ray.tune import Experiment
  from ray.tune.search.util import logger
  from ray.tune.search.variant_generator import generate_variants
label_desc: Use image node_id 45 for calling the SearchSpaceTest obj's underlying member method code with example usage: obj.testPointsToEvaluateBasicVariantAdvanced() without return types