def METHOD_NAME(work_edges, test_edges):
  """ Internal function to quickly calculate the sum of residuals for two lists of edges: work edges, and test edges. """
  work_residual = 0
  test_residual = 0
  # Calculate total graph residual
  for e in work_edges:
      for r in e.residuals():
        work_residual += loss_func(r)
  for e in test_edges:
      for r in e.residuals():
        test_residual += loss_func(r)
  return work_residual, test_residual