(self, sorted=True, flat=False)
Returns top k data items and indexes in each dimension,
        with channels in the first dimension and k in the last dimension.
Returns top k data items and indexes in each dimension,
        with channels in the first dimension and k in the last dimension.
Returns top k data items and indexes in each dimension with channels in the first dimension and k in the last dimension .
def result(self, sorted=True, flat=False):
        '''
        Returns top k data items and indexes in each dimension,
        with channels in the first dimension and k in the last dimension.
        '''
        k = min(self.k, self.next)
        # bti are top indexes relative to buffer array.
        td, bti = self.top_data[:,:self.next].topk(k, sorted=sorted)
        # we want to report top indexes globally, which is ti.
        ti = self.top_index.view(-1)[
                (bti + self.linear_index).view(-1)
                ].view(*bti.shape)
        if flat:
            return td, ti
        else:
            return (td.view(*(self.data_shape + (-1,))),
                    ti.view(*(self.data_shape + (-1,))))
def result ( self , sorted = True , flat = False ) : k = min ( self . k , self . next ) # bti are top indexes relative to buffer array. td , bti = self . top_data [ : , : self . next ] . topk ( k , sorted = sorted ) # we want to report top indexes globally, which is ti. ti = self . top_index . view ( - 1 ) [ ( bti + self . linear_index ) . view ( - 1 ) ] . view ( * bti . shape ) if flat : return td , ti else : return ( td . view ( * ( self . data_shape + ( - 1 , ) ) ) , ti . view ( * ( self . data_shape + ( - 1 , ) ) ) )