Implementing a custom unsupervised loss function for Graph Convolution

I have a graph convolution model built and wanted to implement a custom unsupervised loss function like the one shown in below picture:

Screenshot 2024-05-02 at 2.01.52 PM

Where yv is the learned embedding of a node v and rand denotes random sampling operation over all the nodes

I am new to Pytorch so not sure if this is already implemented. Any help will be sincerely appreciated.