':param env_spec: A spec for the env.
:param hidden_sizes: list of sizes for the fully connected hidden layers
:param hidden_nonlinearity: nonlinearity used for each hidden layer
:return:'

def __init__(self, env_spec, hidden_sizes=(32,), state_include_action=True, hidden_nonlinearity=NL.tanh, learn_std=True, init_std=1.0, output_nonlinearity=None):

    Serializable.quick_init(self, locals())
    super(GaussianGRUPolicy, self).__init__(env_spec)
    assert (len(hidden_sizes) == 1)
    if state_include_action:
        obs_dim = (env_spec.observation_space.flat_dim + env_spec.action_space.flat_dim)
    else:
        obs_dim = env_spec.observation_space.flat_dim
    action_dim = env_spec.action_space.flat_dim
    mean_network = GRUNetwork(input_shape=(obs_dim,), output_dim=action_dim, hidden_dim=hidden_sizes[0], hidden_nonlinearity=hidden_nonlinearity, output_nonlinearity=output_nonlinearity)
    l_mean = mean_network.output_layer
    obs_var = mean_network.input_var
    l_log_std = ParamLayer(mean_network.input_layer, num_units=action_dim, param=lasagne.init.Constant(np.log(init_std)), name='output_log_std', trainable=learn_std)
    l_step_log_std = ParamLayer(mean_network.step_input_layer, num_units=action_dim, param=l_log_std.param, name='step_output_log_std', trainable=learn_std)
    self._mean_network = mean_network
    self._l_log_std = l_log_std
    self._state_include_action = state_include_action
    self._f_step_mean_std = ext.compile_function([mean_network.step_input_layer.input_var, mean_network.step_prev_hidden_layer.input_var], L.get_output([mean_network.step_output_layer, l_step_log_std, mean_network.step_hidden_layer]))
    self._prev_action = None
    self._prev_hidden = None
    self._hidden_sizes = hidden_sizes
    self._dist = RecurrentDiagonalGaussian(action_dim)
    self.reset()
    LasagnePowered.__init__(self, [mean_network.output_layer, l_log_std])
