class_docstr: Attacks a model with word substiutitions using a genetic algorithm.
  
  Args:
      pop_size (int): The population size. Defaults to 60.
      max_iters (int): The maximum number of iterations to use. Defaults to 20.
      temp (float): Temperature for softmax function used to normalize probability dist when sampling parents.
          Higher temperature increases the sensitivity to lower probability candidates.
      give_up_if_no_improvement (bool): If True, stop the search early if no candidate that improves the score is found.
      post_crossover_check (bool): If True, check if child produced from crossover step passes the constraints.
      max_crossover_retries (int): Maximum number of crossover retries if resulting child fails to pass the constraints.
          Applied only when `post_crossover_check` is set to `True`.
          Setting it to 0 means we immediately take one of the parents at random as the child upon failure.
docstr: Initialize a population of size `pop_size` with `initial_result`
  Args:
      initial_result (GoalFunctionResult): Original text
      pop_size (int): size of population
  Returns:
      population as `list[PopulationMember]`
code: def _initialize_population(self, initial_result, pop_size):
      """
      Initialize a population of size `pop_size` with `initial_result`
      Args:
          initial_result (GoalFunctionResult): Original text
          pop_size (int): size of population
      Returns:
          population as `list[PopulationMember]`
      """
      words = initial_result.attacked_text.words
      num_candidate_transformations = np.zeros(len(words))
      transformed_texts = self.get_transformations(
          initial_result.attacked_text,
          original_text=initial_result.attacked_text,
      )
      for transformed_text in transformed_texts:
          diff_idx = next(
              iter(
                  transformed_text.attack_attrs[
                      "newly_modified_indices"
                  ]
              )
          )
          num_candidate_transformations[diff_idx] += 1
  
      # Just b/c there are no replacements now doesn't mean we never want to select the word for perturbation
      # Therefore, we give small non-zero probability for words with no replacements
      # Epsilon is some small number to approximately assign small probability
      min_num_candidates = np.amin(num_candidate_transformations)
      epsilon = max(1, int(min_num_candidates * 0.1))
      for i in range(len(num_candidate_transformations)):
          num_candidate_transformations[i] = max(
              num_candidate_transformations[i], epsilon
          )
  
      population = []
      for _ in range(pop_size):
          pop_member = PopulationMember(
              initial_result.attacked_text,
              initial_result,
              attributes={
                  "num_candidate_transformations": np.copy(
                      num_candidate_transformations
                  )
              },
          )
          # Perturb `pop_member` in-place
          pop_member = self._perturb(pop_member, initial_result)
          population.append(pop_member)
  
      return population
  
file_path: TextAttack/textattack/search_methods/alzantot_genetic_algorithm.py
imports: import numpy
  from textattack.search_methods import GeneticAlgorithm, PopulationMember
label_desc: Use image node_id 5 for calling the AlzantotGeneticAlgorithm obj's underlying member method code with example usage: obj._initialize_population(initial_result, pop_size) and returns: population