How to speed up code with pytorch

I want to speed up the code with pytorch, anyone has ideas? thanks a lot.

jrange = range(c)
    for i in range(r):
        for j in jrange:
            min_list = [D0[i, j].item()]
            for k in range(1, warp + 1):
                i_k = min(i + k, r)
                j_k = min(j + k, c)
                min_list += [D0[i_k, j].item() * s, D0[i, j_k].item() * s]
            D1[i, j] = D1[i, j] + min(min_list)