tools/autograd/load_derivatives.py
def match_declarations_with_autograd_functions(declarations, autograd_functions):
    """Sets the "derivative" key on declarations to matching autograd functions

    In-place functions will use the out-of-place derivative definition if there
    is no in-place specific derivative.
    """

    functions_by_signature = {f['signature']: f for f in autograd_functions}

    def find_function(declaration):
        signature = get_signature(declaration)
        if signature in functions_by_signature:
            return functions_by_signature[signature]

        # if there is no exact match look for the out-of-place signature.
        # i.e mul() for mul_() or mul_out()
        signature = get_signature(declaration, use_base_variant=True)
        return functions_by_signature.get(signature)

    for declaration in declarations:
        declaration['derivative'] = find_function(declaration)
Sets the "derivative" key on declarations to matching autograd functions

    In-place functions will use the out-of-place derivative definition if there
    is no in-place specific derivative.
    
Sets the "derivative" key on declarations to matching autograd functions
In-place functions will use the out-of-place derivative definition if there
is no in-place specific derivative.
Sets the " derivative " key on declarations to matching autograd functions In - place functions will use the out - of - place derivative definition if there is no in - place specific derivative .
def match_declarations_with_autograd_functions(declarations, autograd_functions):
    functions_by_signature = {f['signature']: f for f in autograd_functions}
    def find_function(declaration):
        signature = get_signature(declaration)
        if signature in functions_by_signature:
            return functions_by_signature[signature]
        signature = get_signature(declaration, use_base_variant=True)
        return functions_by_signature.get(signature)
    for declaration in declarations:
        declaration['derivative'] = find_function(declaration)
def match_declarations_with_autograd_functions ( declarations , autograd_functions ) : functions_by_signature = { f [ 'signature' ] : f for f in autograd_functions } def find_function ( declaration ) : signature = get_signature ( declaration ) if signature in functions_by_signature : return functions_by_signature [ signature ] signature = get_signature ( declaration , use_base_variant = True ) return functions_by_signature . get ( signature ) for declaration in declarations : declaration [ 'derivative' ] = find_function ( declaration )
Sets the "derivative" key on declarations to matching autograd functions
In-place functions will use the out-of-place derivative definition if there
is no in-place specific derivative.
Sets the " derivative " key on declarations to matching autograd functions In - place functions will use the out - of - place derivative definition if there is no in - place specific derivative .
"""Sets the "derivative" key on declarations to matching autograd functions

    In-place functions will use the out-of-place derivative definition if there
    is no in-place specific derivative.
    """ # if there is no exact match look for the out-of-place signature. # i.e mul() for mul_() or mul_out()
declarations
autograd_functions