def dist(x, y, S):
	"""
	Mahalanobis distance:
	d(x,y) = \\sqrt( (x-y)^T*S^-1*(x-y) )
	where S^-1 = diag(1/s_i^2 for s_i in std)
	Input must be torch.Tensor((1,N)) for x,y,S
	"""
	d = ((x-y).pow(2)/S).sum(1).sqrt()
	return d