docstr: Run the off-policy evaluator to get a score for the goodness of the new policy, based on the dataset,
  which was collected using other policy(ies).
  
  References:
  - Sutton, R. S. & Barto, A. G. Reinforcement Learning: An Introduction. Chapter 5.5.
  - https://people.cs.umass.edu/~pthomas/papers/Thomas2015c.pdf
  - http://videolectures.net/deeplearning2017_thomas_safe_rl/
  
  :return: the evaluation score
docstr_tok: ["Run","the","off-policy","evaluator","to","get","a","score","for","the","goodness","of","the","new","policy",",","based","on","the","dataset",",","which","was","collected","using","other","policy","(","ies",")",".","References",":","-","Sutton",",","R.","S.","&","Barto",",","A.","G.","Reinforcement","Learning",":","An","Introduction",".","Chapter","5.5",".","-","https",":","\/\/people.cs.umass.edu\/~pthomas\/papers\/Thomas2015c.pdf","-","http",":","\/\/videolectures.net\/deeplearning2017_thomas_safe_rl\/",":","return",":","the","evaluation","score"]
code: def evaluate(evaluation_dataset_as_episodes: List[Episode]) -> float:
      """
      Run the off-policy evaluator to get a score for the goodness of the new policy, based on the dataset,
      which was collected using other policy(ies).
  
      References:
      - Sutton, R. S. & Barto, A. G. Reinforcement Learning: An Introduction. Chapter 5.5.
      - https://people.cs.umass.edu/~pthomas/papers/Thomas2015c.pdf
      - http://videolectures.net/deeplearning2017_thomas_safe_rl/
  
      :return: the evaluation score
      """
  
      # Weighted Importance Sampling
      per_episode_w_i = []
  
      for episode in evaluation_dataset_as_episodes:
          w_i = 1
          for transition in episode.transitions:
              w_i *= (
                  transition.info["softmax_policy_prob"][
                      transition.action
                  ]
                  / transition.info["all_action_probabilities"][
                      transition.action
                  ]
              )
          per_episode_w_i.append(w_i)
  
      total_w_i_sum_across_episodes = sum(per_episode_w_i)
  
      wis = 0
      if total_w_i_sum_across_episodes != 0:
          for i, episode in enumerate(evaluation_dataset_as_episodes):
              if len(episode.transitions) != 0:
                  wis += (
                      per_episode_w_i[i]
                      * episode.transitions[0].n_step_discounted_rewards
                  )
          wis /= total_w_i_sum_across_episodes
  
      return wis
  
imports: from typing import List
  import numpy
  from rl_coach.core_types import Episode
label_desc: Use image node_id 1 for calling the WeightedImportanceSampling obj's underlying member method code with example usage: obj.evaluate(evaluation_dataset_as_episodes) and returns: wis