#NEWLINE# def __new__( cls , connection = None , options = None , floatX = None , **kwargs ) : #NEWLINE# #INDENT# if ( options is None ) : #NEWLINE# #INDENT# options = kwargs #NEWLINE# #UNINDENT# if ( floatX is not None ) : #NEWLINE# #INDENT# theano . config . floatX = floatX #NEWLINE# #UNINDENT# addons = options . get ( 'addons' ) #NEWLINE# if ( not addons ) : #NEWLINE# #INDENT# cls . main_class = cls #NEWLINE# return super ( GradientDescent , cls ) . __new__ ( cls ) #NEWLINE# #UNINDENT# identified_types = [ ] #NEWLINE# for addon_class in addons : #NEWLINE# #INDENT# opt_class_type = getattr ( addon_class , 'addon_type' , None ) #NEWLINE# if ( opt_class_type not in cls . supported_addon_types ) : #NEWLINE# #INDENT# opt_class_name = addon_class . __name__ #NEWLINE# supported_opts = ', ' . join ( addon_types . values ( ) ) #NEWLINE# raise ValueError ( 'Invalid add-on class `{}`. Class supports only {}' . format ( opt_class_name , supported_opts ) ) #NEWLINE# #UNINDENT# if ( opt_class_type in identified_types ) : #NEWLINE# #INDENT# raise ValueError ( 'There can be only one add-on class with type `{}`' . format ( addon_types [ opt_class_type ] ) ) #NEWLINE# #UNINDENT# identified_types . append ( opt_class_type ) #NEWLINE# #UNINDENT# new_class_name = ( cls . __name__ + '' . join ( ( class_ . __name__ for class_ in addons ) ) ) #NEWLINE# mro_classes = tuple ( ( list ( addons ) + [ cls ] ) ) #NEWLINE# new_class = type ( new_class_name , mro_classes , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# new_class . main_class = cls #NEWLINE# return super ( GradientDescent , new_class ) . __new__ ( new_class )