Move numpy_scalar outside of the function that use it.

Indent what is inside. I'll use that in the next commit. This will make the change more visible.
Make get_scalar_constant_value() recurse less.
Make opt faster by calling get_scalar_constant_value() only on constant.

This last commit finish to bring from 584s to 66s the slow scan test:
theano/scan_module/tests/test_scan.py:T_Scan.test_hessian_bug_grad_grad_two_scans

The changed optimization:

local_abs_merge, local_mul_switch_sink,
local_upcast_elemwise_constant_inputs,
local_remove_switch_const_con

are called on nodes that aren't yet part of the graph, during
local_subtensor_merge optimization. They aren't supposed to work on
node that are in the graph, but as they called
get_scalar_constant_value() they traversed it very frequently!

This pre_greedy_local_optimizer call is needed as it would introduce
too much scrapt that will be optimized away. So we preoptimize the
graph.

As now we do the constant_folding in the phase
(canonicalize/stabilize/specialize) where those changed opt are used,
they can work directly on Constant. Other opt will make sure their
inputs get constant if possible.
Re-enable some call to get_scalar_constant_value, but disable the tracking of elemwise.
some pep8
Add in the pickle info the on_unused_input parameter
Merge pull request #1797 from nouiz/fast_opt

Make the slow scan test fast!