# Path: compiler_opt/rl/constant.py
# BASE_DIR = 'compiler_opt/rl'
# BASE_MODULE_DIR = 'compiler_opt.rl'
# DELTA = 0.01
#   BEHAVIORAL_CLONE = 0
#   DQN = 1
#   PPO = 2
# class AgentName(enum.Enum):


import concurrent
import dataclasses
import json
import multiprocessing
import subprocess
import threading
import tensorflow as tf
from typing import Dict, List, Optional, Tuple
from compiler_opt.rl import constant
          k: RewardStat(v[1], v[1]) for (k, v) in default_result.items()
      }

    if tf_policy_path:
      policy_result = self._compile_fn(
          file_paths,
          tf_policy_path,
          reward_only=False,
          cancellation_manager=cancellation_manager)
    else:
      policy_result = default_result

    sequence_example_list = []
    rewards = []
    for k, v in policy_result.items():
      sequence_example = v[0]
      policy_reward = v[1]
      if k not in reward_stat:
        raise ValueError(
            'Example %s does not exist under default policy for module %s' %
            (k, file_paths[0]))
      default_reward = reward_stat[k].default_reward
      moving_average_reward = reward_stat[k].moving_average_reward
      sequence_example = _postprocessing_sequence_example(
          sequence_example, moving_average_reward, policy_reward)
      sequence_example_list.append(sequence_example.SerializeToString())
      reward_stat[k].moving_average_reward = (
          moving_average_reward * self._moving_average_decay_rate +
          policy_reward * (1 - self._moving_average_decay_rate))
      rewards.append(1 - (policy_reward + constant.DELTA) /

# Path: compiler_opt/rl/constant.py
# BASE_DIR = 'compiler_opt/rl'
# BASE_MODULE_DIR = 'compiler_opt.rl'
# DELTA = 0.01
#   BEHAVIORAL_CLONE = 0
#   DQN = 1
#   PPO = 2
# class AgentName(enum.Enum):


# Path: compiler_opt/rl/compilation_runner.py
import concurrent
import dataclasses
import json
import multiprocessing
import subprocess
import threading
import tensorflow as tf
from typing import Dict, List, Optional, Tuple
from compiler_opt.rl import constant

          k: RewardStat(v[1], v[1]) for (k, v) in default_result.items()
      }

    if tf_policy_path:
      policy_result = self._compile_fn(
          file_paths,
          tf_policy_path,
          reward_only=False,
          cancellation_manager=cancellation_manager)
    else:
      policy_result = default_result

    sequence_example_list = []
    rewards = []
    for k, v in policy_result.items():
      sequence_example = v[0]
      policy_reward = v[1]
      if k not in reward_stat:
        raise ValueError(
            'Example %s does not exist under default policy for module %s' %
            (k, file_paths[0]))
      default_reward = reward_stat[k].default_reward
      moving_average_reward = reward_stat[k].moving_average_reward
      sequence_example = _postprocessing_sequence_example(
          sequence_example, moving_average_reward, policy_reward)
      sequence_example_list.append(sequence_example.SerializeToString())
      reward_stat[k].moving_average_reward = (
          moving_average_reward * self._moving_average_decay_rate +
          policy_reward * (1 - self._moving_average_decay_rate))
      rewards.append(1 - (policy_reward + constant.DELTA) /

                     (default_reward + constant.DELTA))