import torch


def abs_loss(labels, predictions):
	""" Square loss function

	Args:
		labels (array[float]): 1-d array of labels
		predictions (array[float]): 1-d array of predictions
	Returns:
		float: square loss
	"""
	# In Deep Q Learning
	# labels = target_action_value_Q
	# predictions = action_value_Q

	# loss = 0
	# for l, p in zip(labels, predictions):
	# 	loss = loss + (l - p) ** 2
	# loss = loss / len(labels)

	# loss = nn.MSELoss()
	output = torch.abs(predictions - labels)
	output = torch.sum(output) / len(labels)
	# output = loss(torch.tensor(predictions), torch.tensor(labels))
	# print("LOSS OUTPUT")
	# print(output)

	return output