'Return the cost tensor in the graph.
Used by some of the tensorpack :class:`Trainer` which assumes single-cost models.
You can ignore this method (or just use :class:`ModelDescBase`)
if you use your own trainer with more than one cost.
It calls :meth:`ModelDesc._get_cost()` which by default returns
``self.cost``. You can override :meth:`_get_cost()` if needed.
This function also applies the collection
``tf.GraphKeys.REGULARIZATION_LOSSES`` to the cost automatically.'

def get_cost(self):

    cost = self._get_cost()
    reg_cost = regularize_cost_from_collection()
    if (reg_cost is not None):
        return tf.add(cost, reg_cost, name='cost_with_regularizer')
    else:
        return cost
