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)

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: at

For an up-to-date version, check block_diag() in in my pylabyk library: