<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_loss(self, loss, name=None, regularization=False, add_summaries=True):
 """Append a loss to the total loss for the network. Args: loss: append this loss operation name: The name for this loss, defaults to loss.op.name regularization: Set to True if this is a regularization loss. add_summaries: Set to True if you want to see scalar and average summary. """

    # TODO(eiderman): Strip name out and just rely on the name scope.
    _ = name  # Eliminates pylint warning.
    if regularization:
      self._g.add_to_collection(GraphKeys.REGULARIZATION_LOSSES, loss)

    tf.add_to_collection(GraphKeys.LOSSES, loss)
    if add_summaries:
      self.add_scalar_summary(loss, 'loss')
      self.add_average_summary(loss, 'loss_average')