my loss is like this:
loss = np.sum(np.square(A-B))
how to write help function that would carry out "earlystopping" like in Keras?