code: def generate_logs(episodes: int, max_horizon: int, policy: RLPolicy):
      """
      Args:
          episodes: number of episodes to generate
          max_horizon: max horizon of each episode
          policy: RLPolicy which uses real-valued states
      """
      log = []
      env = gym.make("CartPole-v0")
      for _ in range(episodes):
          init_state = env.reset()
          cur_state = init_state
          mdp = []
          for _ in range(max_horizon):
              action_dist = policy(State(cur_state))
              action = action_dist.sample()[0].value
              action_prob = action_dist.probability(Action(action))
              next_state, _, done, _ = env.step(action)
              mdp.append(
                  Transition(
                      last_state=State(cur_state),
                      action=Action(action),
                      action_prob=action_prob,
                      state=State(next_state),
                      reward=1.0,
                      status=Transition.Status.NORMAL,
                  )
              )
              cur_state = next_state
              if done:
                  log.append(mdp)
                  break
          log.append(mdp)
      return log
  
imports: import logging
  import gym
  import torch
  from reagent.ope.estimators.sequential_estimators import Action, ActionDistribution, ActionSpace, IPSEstimator, Model, NeuralDualDICE, RandomRLPolicy, RewardProbability, RLEstimatorInput, RLPolicy, State, StateDistribution, Transition
  from reagent.ope.utils import RunningAverage
label_desc: Use image node_id 1 for calling a global function with example usage: generate_logs(episodes, max_horizon, policy) and returns: log