I assume you are referring to these lines of code:
with torch.no_grad():
    bound = compute_edts_forhdloss(targets.cpu().numpy() > 0.5)

If so, the torch.no_grad() wrapper shouldn’t make any difference, since you are passing numpy arrays to the method, so Autograd won’t be able to track these operations anyway.
Generally, the guard is used to avoid gradient computation explicitly and thus not creating the computation graph. Autograd won’t track the operations inside the block. If no used tensors require gradients, using this guard shouldn’t make any difference.