def METHOD_NAME(self):
    """
    Create callback function object which can be used as a function_post_hook argument of backward().
    """
    if not (self.trace_nan or self.trace_inf):
        return None
    # Perform F.isnan and then F.sum to check the output of incoming function contains the nan value.
    def callback(f):
        # For the first time to check this function.
        self._add_key(f, self.key_to_stat_bwd)
        # apply callback to check the outputs of this function has nan values or not.
        nan = []
        if self.trace_nan:
            nan = [F.sum(F.isnan(i.grad)) for i in f.inputs]
        inf = []
        if self.trace_inf:
            inf = [F.sum(F.isinf(i.grad)) for i in f.inputs]
        self.key_to_stat_bwd[f].update({
            "inf": inf,
            "nan": nan,
            # rank might be changed between each iteration.
            "rank": f.rank,
        })
    return callback