code: def compute_action(self, node):
      initial_state = copy.deepcopy(node.state)
      for _ in range(self.num_sims):
          node.env.set_state(copy.deepcopy(initial_state))
          leaf = node.select()
          if leaf.done:
              value = -leaf.reward * 10
          else:
              child_priors, value = self.model.compute_priors_and_value(
                  leaf.obs
              )
              if self.add_dirichlet_noise:
                  child_priors = (1 - self.dir_epsilon) * child_priors
                  child_priors += (
                      self.dir_epsilon
                      * np.random.dirichlet(
                          [self.dir_noise] * child_priors.size
                      )
                  )
  
              leaf.expand(child_priors)
          leaf.backup(value)
  
      # Tree policy target (TPT)
      tree_policy = node.child_number_visits / node.number_visits
      tree_policy = tree_policy / np.max(
          tree_policy
      )  # to avoid overflows when computing softmax
      tree_policy = np.power(tree_policy, self.temperature)
      tree_policy *= node.valid_actions
      tree_policy = tree_policy / np.sum(tree_policy)
      epsilon_exploration = np.random.choice(
          [True, False], p=[self.epsilon, 1 - self.epsilon]
      )
      if self.exploit and not epsilon_exploration:
          # if exploit then choose action that has the maximum
          # tree policy probability
          action = np.argmax(tree_policy)
      else:
          # otherwise sample an action according to tree policy probabilities
          action = np.random.choice(
              np.arange(node.action_space_size), p=tree_policy
          )
      assert node.valid_actions[action] == 1
      node.env.set_state(initial_state)
      return tree_policy, action, node.children[action]
  
imports: import collections
  import copy
  import math
  import numpy
label_desc: Use image node_id 2 for calling the MCTS obj's underlying member method code with example usage: obj.compute_action(node) and returns: tree_policy,  action,  node