Scan push out sum of dot

This is work in progress to implement to optimization necessary to push a "Sum of dots" out of a scan. It is **not** ready for merge because the optimization doesn't get applied in the unit test TestPushOutSumOfDot.test_non_zero_init() which means that there is currently no test for the case where the initial value of the scan output to which the dot products are added is non-zero.

The optimization is, however, correctly applied in the TestPushOutSumOfDot.test_machine_translation() test case which comes from from https://github.com/rizar/scan-grad-speed

This also includes some refactoring of the optimization PushOutScanOutput to make the code simpler and more readable and also factor out the bits of code that are common between the different use cases of the optimization.
the `owner` field of a variable is always `None` or an Apply instance.  You should not need to explicitly check for `isinstance(..., Apply)`.