'Return the implementation of function *fn* for signature *sig*.
The return value is a callable with the signature (builder, args).'

def get_function(self, fn, sig, _firstcall=True):

    sig = sig.as_function()
    if isinstance(fn, (types.Function, types.BoundFunction, types.Dispatcher)):
        key = fn.get_impl_key(sig)
        overloads = self._defns[key]
    else:
        key = fn
        overloads = self._defns[key]
    try:
        return _wrap_impl(overloads.find(sig.args), self, sig)
    except NotImplementedError:
        pass
    if isinstance(fn, types.Type):
        try:
            return self.get_function(type(fn), sig)
        except NotImplementedError:
            pass
    if _firstcall:
        self.refresh()
        return self.get_function(fn, sig, _firstcall=False)
    raise NotImplementedError(('No    definition    for    lowering    %s%s' % (key, sig)))
