#NEWLINE# @ recurrent #NEWLINE# def do_apply( self , **kwargs ) : #NEWLINE# #INDENT# 'Process a sequence attending the attended context every step.\n\n        In addition to the original sequence this method also requires\n        its preprocessed version, the one computed by the `preprocess`\n        method of the attention mechanism. Unknown keyword arguments\n        are passed to the wrapped transition.\n\n        Parameters\n        ----------\n        \\*\\*kwargs\n            Should contain current inputs, previous step states, contexts,\n            the preprocessed attended context, previous step glimpses.\n\n        Returns\n        -------\n        outputs : list of :class:`~tensor.TensorVariable`\n            The current step states and glimpses.\n\n        ' #NEWLINE# attended = kwargs [ self . attended_name ] #NEWLINE# preprocessed_attended = kwargs . pop ( self . preprocessed_attended_name ) #NEWLINE# attended_mask = kwargs . get ( self . attended_mask_name ) #NEWLINE# if self . add_contexts : #NEWLINE# #INDENT# kwargs . pop ( self . attended_name ) #NEWLINE# kwargs . pop ( self . attended_mask_name , None ) #NEWLINE# #UNINDENT# sequences = dict_subset ( kwargs , self . _sequence_names , pop = True , must_have = False ) #NEWLINE# glimpses = dict_subset ( kwargs , attended_mask . _glimpse_names , pop = True ) #NEWLINE# sequences_without_mask = { name : variable for ( name , variable ) in sequences . items ( ) if ( 'mask' not in name ) } #NEWLINE# sequences . update ( self . distribute . apply ( as_dict = True , ** dict_subset ( dict_union ( sequences_without_mask , glimpses ) , self . distribute . apply . inputs ) ) ) #NEWLINE# current_states = self . transition . apply ( iterate = False , as_dict = True , ** dict_union ( sequences , kwargs ) ) #NEWLINE# glimpses_needed = dict_subset ( glimpses , self . previous_glimpses_needed ) #NEWLINE# current_glimpses = self . attention . take_glimpses ( as_dict = True , ** dict_union ( current_states , glimpses_needed , { #NEWLINE# #INDENT# self . attended_name : attended , #NEWLINE# self . attended_mask_name : attended_mask , #NEWLINE# self . preprocessed_attended_name : preprocessed_attended , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# return ( list ( current_states . values ( ) ) + list ( current_glimpses . values ( ) ) )