code: def simulate_reward(
      slate: List[Document], prng: np.random.RandomState
  ):
      reward = 0
      position = 0
      n = len(slate)
      if not n:
          return 0  # Bail if slate is empty
      comparison = slate[position].tap
      roll = prng.rand()
      done = comparison < roll
      while not done:
          reward += slate[position].quality
          comparison = 1 - slate[position].abandon
          roll = prng.rand()
          position += 1
          done = (comparison < roll) or (position >= n)
      return reward
  
imports: from collections import namedtuple
  from typing import List, Optional
  import gym
  import numpy
  from gym.utils import seeding
  from gym.wrappers.time_limit import TimeLimit
  from reagent.core.dataclasses import dataclass
  from reagent.gym.envs.env_wrapper import EnvWrapper
  from reagent.gym.envs.recsim import RecsimObsPreprocessor
  from reagent.gym.envs.wrappers.recsim import ValueWrapper
  from scipy.special import expit, logit
label_desc: Use image node_id 1 for calling a global function with example usage: simulate_reward(slate, prng) and returns: reward, int