title: Evaluation of a symbolic tensor used as a metric and to build loss
body: <p>In my Tensorflow 2.4 training code, I have a composed loss from which I want to monitor each component evolution throughout the training stage.</p>
  <p>Here is a sample of what I am doing:</p>
  <pre><code>model = buildModel() # returns a tf.keras.Model object
  
  T_score1 = score1_function(model.output)
  T_score2 = score2_function(model.output)
  
  loss = 0.9 * T_score1 + 0.1 * T_score2
  
  model.add_loss(loss)
  model.add_metric(T_score1, &quot;score1&quot;)
  model.add_metric(T_score2, &quot;score2&quot;)
  </code></pre>
  <p>Hence, I use <code>T_score1</code> and <code>T_score2</code> both in the loss computation and as a metric, but I am not sure what <code>add_loss</code> and <code>add_metric</code> do exactly (aside from embedding my custom functions in keras objects).</p>
  <p><strong>Question</strong>: are <code>T_score1</code> and <code>T_score2</code> evaluated twice (for the loss <strong>and</strong> as a metric) or once (since they are symbolic tensors)? I.e., is there only one node for each of them in the Graph of operations, or are they duplicated?</p>