code: def _reweights_categorical(
      self,
      discrete_distribution: DiscreteHyperparameterDistribution,
      trial_hyperparameters: List[HPSampledValue],
  ) -> Union[Choice, PriorityChoice]:
      # For discrete categorical distribution
      # We need to reweights probability depending on trial counts.
      probas: List[float] = discrete_distribution.probabilities()
      values: List[Any] = discrete_distribution.values()
  
      number_probas = len(probas)
  
      # Since the reweighted is proportional to N*p_i + C_i,
      # where N is the number of probas, p_i is the original probas and c_i is the count.
      reweighted_probas = np.array(number_probas) * probas
  
      # Count number of occurence for each values.
      count_trials = Counter(trial_hyperparameters)
      values_keys = list(count_trials.keys())
      counts = list(count_trials.values())
  
      for value_key, count in zip(values_keys, counts):
          # find index in the orignal probas and values.
          index_value = values.index(value_key)
  
          # Calculate reweigthed proba.
          reweighted_probas[index_value] += count
  
      # Normalize reweighted probas
      reweighted_probas = np.array(reweighted_probas)
      reweighted_probas = reweighted_probas / np.sum(reweighted_probas)
  
      if isinstance(discrete_distribution, PriorityChoice):
          return PriorityChoice(values, probas=reweighted_probas)
  
      return Choice(values, probas=reweighted_probas)
  
imports: from collections import Counter
  from operator import itemgetter
  from typing import Any, List, Tuple, Union
  import numpy
  from neuraxle.hyperparams.distributions import Choice, DiscreteHyperparameterDistribution, DistributionMixture, HPSampledValue, HyperparameterDistribution, LogSpaceDistributionMixin, PriorityChoice, Quantized
  from neuraxle.hyperparams.space import HyperparameterSamples, HyperparameterSpace
  from neuraxle.metaopt.data.reporting import RoundReport, TrialReport
  from neuraxle.metaopt.optimizer import BaseHyperparameterOptimizer, GridExplorationSampler
label_desc: Use image node_id 5 for calling the _DividedMixturesFactory obj's underlying member method code with example usage: obj._reweights_categorical(discrete_distribution, trial_hyperparameters) and returns: Choice, PriorityChoice