code: def genome_mutation(candidate):
      
      size = len(candidate)
      prob = random.random()
      if prob > .5:    # Inversion
          p = random.randint(0, size-1)
          q = random.randint(0, size-1)
          if p > q:
              p, q = q, p
          q += 1
          s = candidate[p:q]
          x = candidate[:p] + s[::-1] + candidate[q:]
          return creator.Individual(x),
      else:            # Insertion
          p = random.randint(0, size-1)
          q = random.randint(0, size-1)
          cq = candidate.pop(q)
          candidate.insert(p, cq)
          return candidate,
docs: Return the mutants created by inversion mutation on the candidates.
  
      This function performs inversion or insertion. It randomly chooses two
      locations along the candidate and reverses the values within that
      slice. Insertion is done by popping one item and insert it back at random
      position.