def set_monitor(module):
    """ Defines the monitor method on the module. """
    def monitor(name, tensor,
                track_data=True,
                track_grad=True):
        """
        Register the tensor under the name given (now a string)
        and track it based on the track_data and track_grad arguments.
        """
        module.monitored_vars[name] = {
            'tensor':tensor,
            'track_data':track_data,
            'track_grad':track_grad,
        }
    module.monitor = monitor
Defines the monitor method on the module.