<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_scalar_summary(self, x, tag=None):
 """Adds a scalar summary for x."""

    if not self.summary_collections:
      return
    with self.g.as_default():
      tag = tag or _tag_for(x.name)
      summary = (tf.summary.scalar(
          tag, x, collections=self.summary_collections))
      return summary