I want to write a loss layer, I have its numpy implementation, but it involves some complicate indexing and masking during the forward and backward, I used “np.subtract.outer()”, scipy.spatial.distance’s “cdist()” or sklearn.metrics.pairwise’s “pairwise_distances()”, and “np.einsum(‘ik,jk->ijk’, …)” . Until now I couldn’t find an easy way to achieve these operations using tensor, can anyone give some suggestions? thanks.