class_docstr: This hyperparameter space optimizer is similar to a grid search, however, it does
  try to greedily sample maximally different points in the space to explore it. This space
  optimizer has a fixed pseudorandom exploration method that makes the sampling reproductible.
  
  When over the expected_n_trials (if sampling too much), the sampler will turn
  to a non-seeded random search.
  
  It may be good for space exploration before a TPE or for unit tests.
  
  If the expected_n_trials is not set or set to 0, the sampler will guess its ideal
  sampling count and then switch to random search after that.
class_docstr_tok: ["This","hyperparameter","space","optimizer","is","similar","to","a","grid","search",",","however",",","it","does","try","to","greedily","sample","maximally","different","points","in","the","space","to","explore","it",".","This","space","optimizer","has","a","fixed","pseudorandom","exploration","method","that","makes","the","sampling","reproductible",".","When","over","the","expected_n_trials","(","if","sampling","too","much",")",",","the","sampler","will","turn","to","a","non-seeded","random","search",".","It","may","be","good","for","space","exploration","before","a","TPE","or","for","unit","tests",".","If","the","expected_n_trials","is","not","set","or","set","to","0",",","the","sampler","will","guess","its","ideal","sampling","count","and","then","switch","to","random","search","after","that","."]
docstr: Update the grid exploration sampler.
  
  :param round_scope: round scope
  :return: next random hyperparams
docstr_tok: ["Update","the","grid","exploration","sampler",".",":","param","round_scope",":","round","scope",":","return",":","next","random","hyperparams"]
code: def _reinitialize_grid(
      self,
      hp_space: HyperparameterSpace,
      previous_trials_hp: List[HyperparameterSamples],
  ) -> HyperparameterSamples:
      """
      Update the grid exploration sampler.
  
      :param round_scope: round scope
      :return: next random hyperparams
      """
      self._n_sampled = 0
      self.flat_hp_grid_values: OrderedDict[
          str, List[Any]
      ] = OrderedDict()
      self.flat_hp_grid_lens: List[int] = []
      # TODO: could make use of a ND array here to keep track of the grid exploration instead of using random too much. And a walk method picking the most L2-distant point, permutated over the last mod 3 samples to walk awkwardly like [mid, begin, fartest, side, other side] in the ND cube, also avoiding same-seen values.
      self._seen_hp_grid_values: Set[Tuple[int]] = set()
  
      self._generate_grid(hp_space)
      for flat_dict_sample in previous_trials_hp:
          self._reshuffle_grid()
  
          vals: Tuple[int] = tuple(flat_dict_sample.values())
          self._seen_hp_grid_values.add(vals)
  
imports: import copy
  import itertools
  import math
  import operator
  import random
  import warnings
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from functools import reduce
  from typing import Any, List, Set, Tuple
  from neuraxle.hyperparams.distributions import ContinuousHyperparameterDistribution, DiscreteHyperparameterDistribution
  from neuraxle.hyperparams.space import FlatDict, HyperparameterSamples, HyperparameterSpace
  from neuraxle.metaopt.data.reporting import RoundReport
label_desc: Use image node_id 3 for calling the GridExplorationSampler obj's underlying member method code with example usage: obj._reinitialize_grid(hp_space, previous_trials_hp) without return types