Co-occurence Matrix based on context window

How can I create a co-occurrence matrix by specifying the context window? I went through the below article by NSS which talks about it but couldn’t understand how to implement it.

My understanding is that CountVectorizer and TfIDF do not take context window into account. However, word2vec and FastText allow that to be specified but then how do I create a matrix from that.

Thanks in advance for the help.