Creating a block diagonal matrix

I need to create a block diagonal matrix, where the block are repeated on the diagonal many times. I would like to do something analogous to this numpy code

import numpy as np

S = np.arange(9).reshape((3, 3))
M = np.kron(np.eye(4), S)
M += np.kron(np.eye(4, 4, 1), S.T)
print(M)

Is there something similar in Pytorch or it is not yet implemented? Will it ever be implemented if that is the case

I made a vectorized implementation on Gist: block_diag.py at https://gist.github.com/yulkang/2e4fc3061b45403f455d7f4c316ab168

For an up-to-date version, check block_diag() in numpytorch.py in my pylabyk library: https://github.com/yulkang/pylabyk/blob/master/numpytorch.py