class_docstr: A GP class, inherited from Optimizer.
  
  This is the designed class to define GP-related
  variables and methods.
  
  References:
      J. Koza. Genetic programming: On the programming of computers by means of natural selection (1992).
docstr: Actually performs the mutation on a single tree (p. 105).
  
  Args:
      space: A TreeSpace object.
      tree: A Node instance to be mutated.
      max_nodes: Maximum number of nodes to be searched.
  
  Returns:
      (Node): A mutated tree.
docstr_tok: ["Actually","performs","the","mutation","on","a","single","tree","(","p.","105",")",".","Args",":","space",":","A","TreeSpace","object",".","tree",":","A","Node","instance","to","be","mutated",".","max_nodes",":","Maximum","number","of","nodes","to","be","searched",".","Returns",":","(","Node",")",":","A","mutated","tree","."]
code: def _mutate(
      self, space: TreeSpace, tree: Node, max_nodes: int
  ) -> Node:
      """Actually performs the mutation on a single tree (p. 105).
  
      Args:
          space: A TreeSpace object.
          tree: A Node instance to be mutated.
          max_nodes: Maximum number of nodes to be searched.
  
      Returns:
          (Node): A mutated tree.
  
      """
  
      mutated_tree = copy.deepcopy(tree)
      mutation_point = int(
          r.generate_uniform_random_number(2, max_nodes)
      )
  
      sub_tree, flag = mutated_tree.find_node(mutation_point)
  
      # If the mutation point's parent is not a root (this may happen when the mutation point is a function),
      # and find_node() stops at a terminal node whose father is a root
      if sub_tree:
          branch = space.grow(space.min_depth, space.max_depth)
  
          # Checks if sub-tree should be positioned in the left
          if flag:
              sub_tree.left = branch
              branch.flag = True
          else:
              sub_tree.right = branch
              branch.flag = False
  
          branch.parent = sub_tree
      else:
          mutated_tree = space.grow(space.min_depth, space.max_depth)
  
      return mutated_tree
  
imports: import copy
  import time
  from typing import Any, Dict, Optional, Tuple
  import numpy
  import opytimizer.math.general
  import opytimizer.math.random
  import opytimizer.utils.exception
  from opytimizer.core import Optimizer
  from opytimizer.core.function import Function
  from opytimizer.core.node import Node
  from opytimizer.core.space import Space
  from opytimizer.spaces.tree import TreeSpace
  from opytimizer.utils import logging
label_desc: Use image node_id 13 for calling the GP obj's underlying member method code with example usage: obj._mutate(space, tree, max_nodes) and returns: mutated_tree