Deep learners will find torch.einsum() helpful in multiple ways. Essentially, you can use it to carry out any sort of operation on two tensors, thus helping circumvent loops. See https://rockt.github.io/2018/04/30/einsum 52 for an intro and a few examples.