code
stringlengths
17
6.64M
def getTests(path, litConfig, testSuiteCache, localConfigCache): (ts, path_in_suite) = getTestSuite(path, litConfig, testSuiteCache) if (ts is None): litConfig.warning(('unable to find test suite for %r' % path)) return ((), ()) if litConfig.debug: litConfig.note(('resolved input %...
def getTestsInSuite(ts, path_in_suite, litConfig, testSuiteCache, localConfigCache): source_path = ts.getSourcePath(path_in_suite) if (not os.path.exists(source_path)): return if (not os.path.isdir(source_path)): lc = getLocalConfig(ts, path_in_suite[:(- 1)], litConfig, localConfigCache) ...
def find_tests_for_inputs(lit_config, inputs): '\n find_tests_for_inputs(lit_config, inputs) -> [Test]\n\n Given a configuration object and a list of input specifiers, find all the\n tests to execute.\n ' actual_inputs = [] for input in inputs: if (os.path.exists(input) or (not input.s...
def load_test_suite(inputs): import platform import unittest from lit.LitTestCase import LitTestCase litConfig = LitConfig.LitConfig(progname='lit', path=[], quiet=False, useValgrind=False, valgrindLeakCheck=False, valgrindArgs=[], noExecute=False, debug=False, isWindows=(platform.system() == 'Windows...
def executeCommand(command, input): p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() exitCode = p.wait() if (exitCode == (- signal.SIGINT)): raise KeyboardInterrupt try: out = str(out.decode('ascii')) ...
def readFile(path): fd = open(path, 'r') return fd.read()
class AliveTest(FileBasedTest): def __init__(self): self.regex = re.compile(';\\s*(ERROR:.*)') self.regex_args = re.compile(';\\s*TEST-ARGS:(.*)') def execute(self, test, litConfig): test = test.getSourcePath() cmd = ['python', 'run.py', test] input = readFile(test) ...
class TestFormat(object): pass
class FileBasedTest(TestFormat): def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, localConfig): source_path = testSuite.getSourcePath(path_in_suite) for filename in os.listdir(source_path): if (filename.startswith('.') or (filename in localConfig.excludes)): ...
class OneCommandPerFileTest(TestFormat): def __init__(self, command, dir, recursive=False, pattern='.*', useTempInput=False): if isinstance(command, str): self.command = [command] else: self.command = list(command) if (dir is not None): dir = str(dir) ...
class TestingProgressDisplay(object): def __init__(self, opts, numTests, progressBar=None): self.opts = opts self.numTests = numTests self.current = None self.progressBar = progressBar self.completed = 0 def finish(self): if self.progressBar: self....
def write_test_results(run, lit_config, testing_time, output_path): try: import json except ImportError: lit_config.fatal('test output unsupported with Python 2.5') data = {} data['__version__'] = lit.__versioninfo__ data['elapsed'] = testing_time data['tests'] = tests_data = [...
def update_incremental_cache(test): if (not test.result.code.isFailure): return fname = test.getFilePath() os.utime(fname, None)
def sort_by_incremental_cache(run): def sortIndex(test): fname = test.getFilePath() try: return (- os.path.getmtime(fname)) except: return 0 run.tests.sort(key=(lambda t: sortIndex(t)))
def main(builtinParameters={}): isWindows = (platform.system() == 'Windows') useProcessesIsDefault = (not isWindows) global options from optparse import OptionParser, OptionGroup parser = OptionParser('usage: %prog [options] {file-or-path}') parser.add_option('', '--version', dest='show_versio...
class LockedValue(object): def __init__(self, value): self.lock = threading.Lock() self._value = value def _get_value(self): self.lock.acquire() try: return self._value finally: self.lock.release() def _set_value(self, value): self...
class TestProvider(object): def __init__(self, tests, num_jobs, queue_impl, canceled_flag): self.canceled_flag = canceled_flag self.queue = queue_impl() for i in range(len(tests)): self.queue.put(i) for i in range(num_jobs): self.queue.put(None) def ca...
class Tester(object): def __init__(self, run_instance, provider, consumer): self.run_instance = run_instance self.provider = provider self.consumer = consumer def run(self): while True: item = self.provider.get() if (item is None): brea...
class ThreadResultsConsumer(object): def __init__(self, display): self.display = display self.lock = threading.Lock() def update(self, test_index, test): self.lock.acquire() try: self.display.update(test) finally: self.lock.release() def t...
class MultiprocessResultsConsumer(object): def __init__(self, run, display, num_jobs): self.run = run self.display = display self.num_jobs = num_jobs self.queue = multiprocessing.Queue() def update(self, test_index, test): self.queue.put((test_index, test.result)) ...
def run_one_tester(run, provider, display): tester = Tester(run, provider, display) tester.run()
class Run(object): '\n This class represents a concrete, configured testing run.\n ' def __init__(self, lit_config, tests): self.lit_config = lit_config self.tests = tests def execute_test(self, test): result = None start_time = time.time() try: ...
def detectCPUs(): '\n Detects the number of CPUs on a system. Cribbed from pp.\n ' if hasattr(os, 'sysconf'): if ('SC_NPROCESSORS_ONLN' in os.sysconf_names): ncpus = os.sysconf('SC_NPROCESSORS_ONLN') if (isinstance(ncpus, int) and (ncpus > 0)): return ncpu...
def mkdir_p(path): 'mkdir_p(path) - Make the "path" directory, if it does not exist; this\n will also make directories for any missing parent directories.' if ((not path) or os.path.exists(path)): return parent = os.path.dirname(path) if (parent != path): mkdir_p(parent) try: ...
def capture(args, env=None): 'capture(command) - Run the given command (or argv list) in a shell and\n return the standard output.' p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) (out, _) = p.communicate() return out
def which(command, paths=None): 'which(command, [paths]) - Look up the given command in the paths string\n (or the PATH environment variable, if unspecified).' if (paths is None): paths = os.environ.get('PATH', '') if os.path.isfile(command): return command if (not paths): p...
def checkToolsPath(dir, tools): for tool in tools: if (not os.path.exists(os.path.join(dir, tool))): return False return True
def whichTools(tools, paths): for path in paths.split(os.pathsep): if checkToolsPath(path, tools): return path return None
def printHistogram(items, title='Items'): items.sort(key=(lambda item: item[1])) maxValue = max([v for (_, v) in items]) power = int(math.ceil(math.log(maxValue, 10))) for inc in itertools.cycle((5, 2, 2.5, 1)): barH = (inc * (10 ** power)) N = int(math.ceil((maxValue / barH))) ...
def executeCommand(command, cwd=None, env=None): p = subprocess.Popen(command, cwd=cwd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, close_fds=kUseCloseFDs) (out, err) = p.communicate() exitCode = p.wait() if (exitCode == (- signal.SIGINT)): raise KeyboardInt...
def normalize(x): x = x.strip() if (len(x) > max_single_length): x = (x[:max_single_length] + ' ...') return x
def sample_sentences(xs, k, group_id): random.shuffle(xs) return '\n'.join([('Group %s: %s' % (group_id, normalize(x))) for x in xs[:k]])
def create_prompt_from_pos_neg_samples(positive_samples, negative_samples, k=K): group_A_text = sample_sentences(positive_samples, k=k, group_id='A') group_B_text = sample_sentences(negative_samples, k=k, group_id='B') prompt = (((group_A_text + '\n\n') + group_B_text) + '\n\n') prompt += 'Compared to...
def describe(pos: List[str], neg: List[str], note: str='', proposer_name: str='t5ruiqi-zhong/t5proposer_0514', verifier_name: str='ruiqi-zhong/t5verifier_0514', save_folder=None): if (save_folder is None): save_folder = ('end2end_jobs/' + str(random.random())) if (not os.path.exists(save_folder)): ...
def sample_sentences(xs, k, group_id): random.shuffle(xs) return '\n'.join([('Group %s: %s' % (group_id, x)) for x in xs[:k]])
def sort_by_score(d): return sorted(d, key=(lambda k: d[k]), reverse=True)
def get_top_percentile(l, p, min_length=10): n = max(int(((len(l) * p) / 100)), min_length) return l[:n]
class Proposer(): def __init__(self, model_name, template_path): self.proposer_name = model_name self.prompt_template = open(template_path).read().strip() def preprocess_texts(self, x2score): return [self.normalize(x) for x in sort_by_score(x2score)] def create_prompt(self, A_bl...
class GPT3Proposer(Proposer): def __init__(self, model_name): super(GPT3Proposer, self).__init__(model_name, 'templates/gpt3_proposer_template.txt') self.discouraged_toks = [4514, 8094, 33, 40798, 392, 273, 14, 11, 981, 4514, 8094, 1448, 33, 347, 1884, 40798, 290, 392, 273, 393, 14, 1220, 837, 11...
class T5Proposer(Proposer): def __init__(self, model_name, verbose=True): super(T5Proposer, self).__init__(model_name, 'templates/t5_ai2_proposer_template.txt') if verbose: print('loading model') self.model = transformers.T5ForConditionalGeneration.from_pretrained(model_name)....
def init_proposer(proposer_name): if (proposer_name[:2] == 't5'): return T5Proposer(proposer_name[2:]) if (proposer_name[:4] == 'gpt3'): return T5Proposer(proposer_name[4:]) raise Exception(('Proposer %s has not been implemented' % proposer_name))
class ISSampler(BatchSampler): '\n Sampler which alternates between live sampling iterations using BatchSampler\n and importance sampling iterations.\n ' def __init__(self, algo, n_backtrack='all', n_is_pretrain=0, init_is=0, skip_is_itrs=False, hist_variance_penalty=0.0, max_is_ratio=0, ess_thresho...
def kong_ess(weights): return (len(weights) / (1 + var(weights)))
class VG(VariantGenerator): @variant def seed(self): return [x for x in range(2)] @variant def fast_batch_size(self): return [20, 50] @variant def fast_learning_rate(self): return [0.5, 1] @variant def meta_batch_size(self): return [20] @variant...
class Algorithm(object): pass
class RLAlgorithm(Algorithm): def train(self): raise NotImplementedError
class BatchSampler(BaseSampler): def __init__(self, algo): '\n :type algo: BatchPolopt\n ' self.algo = algo def start_worker(self): parallel_sampler.populate_task(self.algo.env, self.algo.policy, scope=self.algo.scope) def shutdown_worker(self): parallel_sa...
class BatchPolopt(RLAlgorithm): '\n Base class for batch sampling-based policy optimization methods.\n This includes various policy gradient methods like vpg, npg, ppo, trpo, etc.\n ' def __init__(self, env, policy, baseline, scope=None, n_itr=500, start_itr=0, batch_size=5000, max_path_length=500, ...
def _worker_rollout_policy(G, args): sample_std = args['sample_std'].flatten() cur_mean = args['cur_mean'].flatten() K = len(cur_mean) params = ((np.random.standard_normal(K) * sample_std) + cur_mean) G.policy.set_param_values(params) path = rollout(G.env, G.policy, args['max_path_length']) ...
class CEM(RLAlgorithm, Serializable): def __init__(self, env, policy, n_itr=500, max_path_length=500, discount=0.99, init_std=1.0, n_samples=100, batch_size=None, best_frac=0.05, extra_std=1.0, extra_decay_time=100, plot=False, **kwargs): '\n :param n_itr: Number of iterations.\n :param max...
def sample_return(G, params, max_path_length, discount): G.policy.set_param_values(params) path = rollout(G.env, G.policy, max_path_length) path['returns'] = discount_cumsum(path['rewards'], discount) path['undiscounted_return'] = sum(path['rewards']) return path
class CMAES(RLAlgorithm, Serializable): def __init__(self, env, policy, n_itr=500, max_path_length=500, discount=0.99, sigma0=1.0, batch_size=None, plot=False, **kwargs): '\n :param n_itr: Number of iterations.\n :param max_path_length: Maximum length of a single rollout.\n :param ba...
def parse_update_method(update_method, **kwargs): if (update_method == 'adam'): return partial(lasagne.updates.adam, **ext.compact(kwargs)) elif (update_method == 'sgd'): return partial(lasagne.updates.sgd, **ext.compact(kwargs)) else: raise NotImplementedError
class SimpleReplayPool(object): def __init__(self, max_pool_size, observation_dim, action_dim): self._observation_dim = observation_dim self._action_dim = action_dim self._max_pool_size = max_pool_size self._observations = np.zeros((max_pool_size, observation_dim)) self._a...
class DDPG(RLAlgorithm): '\n Deep Deterministic Policy Gradient.\n ' def __init__(self, env, policy, qf, es, batch_size=32, n_epochs=200, epoch_length=1000, min_pool_size=10000, replay_pool_size=1000000, discount=0.99, max_path_length=250, qf_weight_decay=0.0, qf_update_method='adam', qf_learning_rate=...
class ERWR(VPG, Serializable): '\n Episodic Reward Weighted Regression [1]_\n\n Notes\n -----\n This does not implement the original RwR [2]_ that deals with "immediate reward problems" since\n it doesn\'t find solutions that optimize for temporally delayed rewards.\n\n .. [1] Kober, Jens, and J...
class NOP(BatchPolopt): '\n NOP (no optimization performed) policy search algorithm\n ' def __init__(self, **kwargs): super(NOP, self).__init__(**kwargs) @overrides def init_opt(self): pass @overrides def optimize_policy(self, itr, samples_data): pass @ove...
class NPO(BatchPolopt): '\n Natural Policy Optimization.\n ' def __init__(self, optimizer=None, optimizer_args=None, step_size=0.01, truncate_local_is_ratio=None, **kwargs): if (optimizer is None): if (optimizer_args is None): optimizer_args = dict() opti...
class PPO(NPO, Serializable): '\n Penalized Policy Optimization.\n ' def __init__(self, optimizer=None, optimizer_args=None, **kwargs): Serializable.quick_init(self, locals()) if (optimizer is None): if (optimizer_args is None): optimizer_args = dict() ...
class REPS(BatchPolopt, Serializable): '\n Relative Entropy Policy Search (REPS)\n\n References\n ----------\n [1] J. Peters, K. Mulling, and Y. Altun, "Relative Entropy Policy Search," Artif. Intell., pp. 1607-1612, 2008.\n\n ' def __init__(self, epsilon=0.5, L2_reg_dual=0.0, L2_reg_loss=0.0,...
class TNPG(NPO): '\n Truncated Natural Policy Gradient.\n ' def __init__(self, optimizer=None, optimizer_args=None, **kwargs): if (optimizer is None): default_args = dict(max_backtracks=1) if (optimizer_args is None): optimizer_args = default_args ...
class TRPO(NPO): '\n Trust Region Policy Optimization\n ' def __init__(self, optimizer=None, optimizer_args=None, **kwargs): if (optimizer is None): if (optimizer_args is None): optimizer_args = dict() optimizer = ConjugateGradientOptimizer(**optimizer_ar...
def center_advantages(advantages): return ((advantages - np.mean(advantages)) / (advantages.std() + 1e-08))
def shift_advantages_to_positive(advantages): return ((advantages - np.min(advantages)) + 1e-08)
def sign(x): return ((1.0 * (x >= 0)) - (1.0 * (x < 0)))
class ReplayPool(Serializable): '\n A utility class for experience replay.\n The code is adapted from https://github.com/spragunr/deep_q_rl\n ' def __init__(self, observation_shape, action_dim, max_steps, observation_dtype=np.float32, action_dtype=np.float32, concat_observations=False, concat_length...
def simple_tests(): np.random.seed(222) dataset = ReplayPool(observation_shape=(3, 2), action_dim=1, max_steps=6, concat_observations=True, concat_length=4) for _ in range(10): img = np.random.randint(0, 256, size=(3, 2)) action = np.random.randint(16) reward = np.random.random() ...
def speed_tests(): dataset = ReplayPool(observation_shape=(80, 80), action_dim=1, max_steps=20000, concat_observations=True, concat_length=4) img = np.random.randint(0, 256, size=(80, 80)) action = np.random.randint(16) reward = np.random.random() start = time.time() for _ in range(100000): ...
def trivial_tests(): dataset = ReplayPool(observation_shape=(1, 2), action_dim=1, max_steps=3, concat_observations=True, concat_length=2) img1 = np.array([[1, 1]], dtype='uint8') img2 = np.array([[2, 2]], dtype='uint8') img3 = np.array([[3, 3]], dtype='uint8') dataset.add_sample(img1, 1, 1, False)...
def max_size_tests(): dataset1 = ReplayPool(observation_shape=(4, 3), action_dim=1, max_steps=10, concat_observations=True, concat_length=4, rng=np.random.RandomState(42)) dataset2 = ReplayPool(observation_shape=(4, 3), action_dim=1, max_steps=1000, concat_observations=True, concat_length=4, rng=np.random.Ran...
def test_memory_usage_ok(): import memory_profiler dataset = ReplayPool(observation_shape=(80, 80), action_dim=1, max_steps=100000, concat_observations=True, concat_length=4) last = time.time() for i in range(1000000000): if ((i % 100000) == 0): print(i) dataset.add_sample(...
def main(): speed_tests() max_size_tests() simple_tests()
class VPG(BatchPolopt, Serializable): '\n Vanilla Policy Gradient.\n ' def __init__(self, env, policy, baseline, optimizer=None, optimizer_args=None, **kwargs): Serializable.quick_init(self, locals()) if (optimizer is None): default_args = dict(batch_size=None, max_epochs=1)...
class Baseline(object): def __init__(self, env_spec): self._mdp_spec = env_spec @property def algorithm_parallelized(self): return False def get_param_values(self): raise NotImplementedError def set_param_values(self, val): raise NotImplementedError def fit...
class GaussianConvBaseline(Baseline, Parameterized, Serializable): def __init__(self, env_spec, subsample_factor=1.0, regressor_args=None): Serializable.quick_init(self, locals()) super(GaussianConvBaseline, self).__init__(env_spec) if (regressor_args is None): regressor_args ...
class GaussianMLPBaseline(Baseline, Parameterized, Serializable): def __init__(self, env_spec, subsample_factor=1.0, num_seq_inputs=1, regressor_args=None): Serializable.quick_init(self, locals()) super(GaussianMLPBaseline, self).__init__(env_spec) if (regressor_args is None): ...
class LinearFeatureBaseline(Baseline): def __init__(self, env_spec, reg_coeff=1e-05): self._coeffs = None self._reg_coeff = reg_coeff @overrides def get_param_values(self, **tags): return self._coeffs @overrides def set_param_values(self, val, **tags): self._coef...
class ZeroBaseline(Baseline): def __init__(self, env_spec): pass @overrides def get_param_values(self, **kwargs): return None @overrides def set_param_values(self, val, **kwargs): pass @overrides def fit(self, paths, **kwargs): pass @overrides d...
def get_full_output(layer_or_layers, inputs=None, **kwargs): "\n Computes the output of the network at one or more given layers.\n Optionally, you can define the input(s) to propagate through the network\n instead of using the input variable(s) associated with the network's\n input layer(s).\n\n Pa...
def get_output(layer_or_layers, inputs=None, **kwargs): return get_full_output(layer_or_layers, inputs, **kwargs)[0]
class ParamLayer(L.Layer): def __init__(self, incoming, num_units, param=lasagne.init.Constant(0.0), trainable=True, **kwargs): super(ParamLayer, self).__init__(incoming, **kwargs) self.num_units = num_units self.param = self.add_param(param, (num_units,), name='param', trainable=trainabl...
class OpLayer(L.MergeLayer): def __init__(self, incoming, op, shape_op=(lambda x: x), extras=None, **kwargs): if (extras is None): extras = [] incomings = ([incoming] + extras) super(OpLayer, self).__init__(incomings, **kwargs) self.op = op self.shape_op = shap...
class BatchNormLayer(L.Layer): "\n lasagne.layers.BatchNormLayer(incoming, axes='auto', epsilon=1e-4,\n alpha=0.1, mode='low_mem',\n beta=lasagne.init.Constant(0), gamma=lasagne.init.Constant(1),\n mean=lasagne.init.Constant(0), std=lasagne.init.Constant(1), **kwargs)\n\n Batch Normalization\n\n ...
def batch_norm(layer, **kwargs): "\n Apply batch normalization to an existing layer. This is a convenience\n function modifying an existing layer to include batch normalization: It\n will steal the layer's nonlinearity if there is one (effectively\n introducing the normalization right before the nonli...
class LasagnePowered(Parameterized): def __init__(self, output_layers): self._output_layers = output_layers super(LasagnePowered, self).__init__() @property def output_layers(self): return self._output_layers @overrides def get_params_internal(self, **tags): retu...
def wrapped_conv(*args, **kwargs): copy = dict(kwargs) copy.pop('image_shape', None) copy.pop('filter_shape', None) assert copy.pop('filter_flip', False) (input, W, input_shape, get_W_shape) = args if (theano.config.device == 'cpu'): return theano.tensor.nnet.conv2d(*args, **kwargs) ...
class MLP(LasagnePowered, Serializable): def __init__(self, output_dim, hidden_sizes, hidden_nonlinearity, output_nonlinearity, hidden_W_init=LI.GlorotUniform(), hidden_b_init=LI.Constant(0.0), output_W_init=LI.GlorotUniform(), output_b_init=LI.Constant(0.0), name=None, input_var=None, input_layer=None, input_sh...
class GRULayer(L.Layer): '\n A gated recurrent unit implements the following update mechanism:\n Reset gate: r(t) = f_r(x(t) @ W_xr + h(t-1) @ W_hr + b_r)\n Update gate: u(t) = f_u(x(t) @ W_xu + h(t-1) @ W_hu + b_u)\n Cell gate: c(t) = f_c(x(t) @ W_xc + r(t) * (h(t-1) @ W_hc) + b_...
class GRUStepLayer(L.MergeLayer): def __init__(self, incomings, gru_layer, name=None): super(GRUStepLayer, self).__init__(incomings, name) self._gru_layer = gru_layer def get_params(self, **tags): return self._gru_layer.get_params(**tags) def get_output_shape_for(self, input_sha...
class GRUNetwork(object): def __init__(self, input_shape, output_dim, hidden_dim, hidden_nonlinearity=LN.rectify, output_nonlinearity=None, name=None, input_var=None, input_layer=None): if (input_layer is None): l_in = L.InputLayer(shape=((None, None) + input_shape), input_var=input_var, name...
class ConvNetwork(object): def __init__(self, input_shape, output_dim, hidden_sizes, conv_filters, conv_filter_sizes, conv_strides, conv_pads, hidden_W_init=LI.GlorotUniform(), hidden_b_init=LI.Constant(0.0), output_W_init=LI.GlorotUniform(), output_b_init=LI.Constant(0.0), hidden_nonlinearity=LN.rectify, output...
@contextmanager def suppress_params_loading(): global load_params load_params = False (yield) load_params = True
class Parameterized(object): def __init__(self): self._cached_params = {} self._cached_param_dtypes = {} self._cached_param_shapes = {} def get_params_internal(self, **tags): '\n Internal method to be implemented which does not perform caching\n ' raise ...
class Serializable(object): def __init__(self, *args, **kwargs): self.__args = args self.__kwargs = kwargs def quick_init(self, locals_): if getattr(self, '_serializable_initialized', False): return spec = inspect.getargspec(self.__init__) in_order_args = ...
class Distribution(object): @property def dim(self): raise NotImplementedError def kl_sym(self, old_dist_info_vars, new_dist_info_vars): '\n Compute the symbolic KL divergence of two distributions\n ' raise NotImplementedError def kl(self, old_dist_info, new_di...
class Bernoulli(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): old_p = old_dist_info_vars['p'] new_p = new_dist_info_vars['p'] kl = ((old_p * (TT.log(...
def from_onehot(x_var): ret = np.zeros((len(x_var),), 'int32') (nonzero_n, nonzero_a) = np.nonzero(x_var) ret[nonzero_n] = nonzero_a return ret
class Categorical(Distribution): def __init__(self, dim): self._dim = dim self._srng = RandomStreams() @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): '\n Compute the symbolic KL divergence of two categorical...
class Delta(Distribution): @property def dim(self): return 0 def kl_sym(self, old_dist_info_vars, new_dist_info_vars): return None def kl(self, old_dist_info, new_dist_info): return None def likelihood_ratio_sym(self, x_var, old_dist_info_vars, new_dist_info_vars): ...
class DiagonalGaussian(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): old_means = old_dist_info_vars['mean'] old_log_stds = old_dist_info_vars['log_std'] ...