def learn(<EOL>network,<EOL>env,<EOL>seed=None,<EOL>nsteps=<NUM_LIT:5>,<EOL>total_timesteps=int(<NUM_LIT>),<EOL>vf_coef=<NUM_LIT:0.5>,<EOL>ent_coef=<NUM_LIT>,<EOL>max_grad_norm=<NUM_LIT:0.5>,<EOL>lr=<NUM_LIT>,<EOL>lrschedule='<STR_LIT>',<EOL>epsilon=<NUM_LIT>,<EOL>alpha=<NUM_LIT>,<EOL>gamma=<NUM_LIT>,<EOL>log_interval=<NUM_LIT:100>,<EOL>load_path=None,<EOL>**network_kwargs):
set_global_seeds(seed)<EOL>nenvs = env.num_envs<EOL>policy = build_policy(env, network, **network_kwargs)<EOL>model = Model(policy=policy, env=env, nsteps=nsteps, ent_coef=ent_coef, vf_coef=vf_coef,<EOL>max_grad_norm=max_grad_norm, lr=lr, alpha=alpha, epsilon=epsilon, total_timesteps=total_timesteps, lrschedule=lrschedule)<EOL>if load_path is not None:<EOL><INDENT>model.load(load_path)<EOL><DEDENT>runner = Runner(env, model, nsteps=nsteps, gamma=gamma)<EOL>epinfobuf = deque(maxlen=<NUM_LIT:100>)<EOL>nbatch = nenvs*nsteps<EOL>tstart = time.time()<EOL>for update in range(<NUM_LIT:1>, total_timesteps//nbatch+<NUM_LIT:1>):<EOL><INDENT>obs, states, rewards, masks, actions, values, epinfos = runner.run()<EOL>epinfobuf.extend(epinfos)<EOL>policy_loss, value_loss, policy_entropy = model.train(obs, states, rewards, masks, actions, values)<EOL>nseconds = time.time()-tstart<EOL>fps = int((update*nbatch)/nseconds)<EOL>if update % log_interval == <NUM_LIT:0> or update == <NUM_LIT:1>:<EOL><INDENT>ev = explained_variance(values, rewards)<EOL>logger.record_tabular("<STR_LIT>", update)<EOL>logger.record_tabular("<STR_LIT>", update*nbatch)<EOL>logger.record_tabular("<STR_LIT>", fps)<EOL>logger.record_tabular("<STR_LIT>", float(policy_entropy))<EOL>logger.record_tabular("<STR_LIT>", float(value_loss))<EOL>logger.record_tabular("<STR_LIT>", float(ev))<EOL>logger.record_tabular("<STR_LIT>", safemean([epinfo['<STR_LIT:r>'] for epinfo in epinfobuf]))<EOL>logger.record_tabular("<STR_LIT>", safemean([epinfo['<STR_LIT:l>'] for epinfo in epinfobuf]))<EOL>logger.dump_tabular()<EOL><DEDENT><DEDENT>return model<EOL>
Main entrypoint for A2C algorithm. Train a policy with given network architecture on a given environment using a2c algorithm.

Parameters:
-----------

network:            policy network architecture. Either string (mlp, lstm, lnlstm, cnn_lstm, cnn, cnn_small, conv_only - see baselines.common/models.py for full list)
                    specifying the standard network architecture, or a function that takes tensorflow tensor as input and returns
                    tuple (output_tensor, extra_feed) where output tensor is the last network layer output, extra_feed is None for feed-forward
                    neural nets, and extra_feed is a dictionary describing how to feed state into the network for recurrent neural nets.
                    See baselines.common/policies.py/lstm for more details on using recurrent nets in policies


env:                RL environment. Should implement interface similar to VecEnv (baselines.common/vec_env) or be wrapped with DummyVecEnv (baselines.common/vec_env/dummy_vec_env.py)


seed:               seed to make random number sequence in the alorightm reproducible. By default is None which means seed from system noise generator (not reproducible)

nsteps:             int, number of steps of the vectorized environment per update (i.e. batch size is nsteps * nenv where
                    nenv is number of environment copies simulated in parallel)

total_timesteps:    int, total number of timesteps to train on (default: 80M)

vf_coef:            float, coefficient in front of value function loss in the total loss function (default: 0.5)

ent_coef:           float, coeffictiant in front of the policy entropy in the total loss function (default: 0.01)

max_gradient_norm:  float, gradient is clipped to have global L2 norm no more than this value (default: 0.5)

lr:                 float, learning rate for RMSProp (current implementation has RMSProp hardcoded in) (default: 7e-4)

lrschedule:         schedule of learning rate. Can be 'linear', 'constant', or a function [0..1] -> [0..1] that takes fraction of the training progress as input and
                    returns fraction of the learning rate (specified as lr) as output

epsilon:            float, RMSProp epsilon (stabilizes square root computation in denominator of RMSProp update) (default: 1e-5)

alpha:              float, RMSProp decay parameter (default: 0.99)

gamma:              float, reward discounting parameter (default: 0.99)

log_interval:       int, specifies how frequently the logs are printed out (default: 100)

**network_kwargs:   keyword arguments to the policy / network builder. See baselines.common/policies.py/build_policy and arguments to a particular type of network
                    For instance, 'mlp' network architecture has arguments num_hidden and num_layers.