Theano bug fix

The changes address the following:
1. All the code review comments obtained recently
2. I also provide a cleaner solution where by default the older behavior is used (as was suggested during code review). If the gradient of a matrix needs to be calculated using sparse gradient, it can be done so by enabling a flag( which is currently a attribute). By default the attribute value is False. The application can just set this value before calling T.grad and the optimization will be enabled.
3. From a true object oriented sense, if we wish to provide further abstraction to the client, we can always implement setters and getters in the class but for now I thought this should be fine.
4. Later on in the future, if needed, it can be extended so that constructors of different classes take a attribute which can enable sparse grad , but since this is currently expensive and needs a lots of changes , I decided to follow the above approach.
5. Here is the test log:
(theano-vivek)vvkulkarni@descartes:~/Downloads/graphs_debug_prints_script$ python sparse.py
******Testing advanced and sparse indexing***********
Using advanced Indexing
Time for Forward Pass:  0.199083089828
Time for Backward Pass:  0.731197118759
-----------------------------------------------------
Using sparse indexing
Time for Forward Pass:  0.38062286377
Time for Backward Pass:  5.66594910622
Test Passed
6. Here are the Theano Nose test logs:
----------------------------------------------------------------------
Ran 2145 tests in 596.214s

OK (KNOWNFAIL=17, SKIP=47)