def _final_reward(self) -> float:
    """Computes the final step reward, r_T = S(d_T | q) - S(d_0 | q).

    Returns:
      The final reward.
    """

    if common_flags.INACTION_PENALTY.value < 0:
      # We penalize the learner for not even issuing a query at all.
      if not len(self.state.history) > 1:
        return common_flags.INACTION_PENALTY.value

    current_documents_list = self.get_final_document_list()
    return self._compute_reward(
        current_documents=current_documents_list) - self._compute_reward(
            current_documents=self.state.history[0].documents)
Computes the final step reward, r_T = S(d_T | q) - S(d_0 | q).

    Returns:
      The final reward.
    
language/search_agents/muzero/env.py