import torch


def kronecker(mat1, mat2):
	"""
	kronecker product between 2 2D tensors
	:param mat1: 2d torch.Tensor
	:param mat2: 2d torch.Tensor
	:return: kronecker product of mat1 and mat2
	"""
	s1 = mat1.size()
	s2 = mat2.size()
	return torch.ger(mat1.view(-1), mat2.view(-1)).reshape(*(s1 + s2)).permute([0, 2, 1, 3]).reshape(s1[0] * s2[0], s1[1] * s2[1])