docstr: Computes loss using logits.
docstr_tok: ["Computes","loss","using","logits","."]
code: def add_training_loss(self, final_loss, logits):
      """Computes loss using logits."""
      loss_fn = get_loss_fn(final_loss)  # Get loss function
      task_losses = []
      # label_placeholder of shape (batch_size, n_tasks). Split into n_tasks
      # tensors of shape (batch_size,)
      task_labels = tf.split(
          axis=1,
          num_or_size_splits=self.n_tasks,
          value=self.label_placeholder,
      )
      task_weights = tf.split(
          axis=1,
          num_or_size_splits=self.n_tasks,
          value=self.weight_placeholder,
      )
      for task in range(self.n_tasks):
          task_label_vector = task_labels[task]
          task_weight_vector = task_weights[task]
          # Convert the labels into one-hot vector encodings.
          one_hot_labels = tf.cast(
              tf.one_hot(
                  tf.cast(tf.squeeze(task_label_vector), tf.int32), 2
              ),
              tf.float32,
          )
          # Since we use tf.nn.softmax_cross_entropy_with_logits note that we pass in
          # un-softmaxed logits rather than softmax outputs.
          task_loss = loss_fn(
              logits[task], one_hot_labels, task_weight_vector
          )
          task_losses.append(task_loss)
      # It's ok to divide by just the batch_size rather than the number of nonzero
      # examples (effect averages out)
      total_loss = tf.add_n(task_losses)
      total_loss = tf.math.divide(total_loss, self.batch_size)
      return total_loss
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import warnings
  import os
  import sys
  import numpy
  import tensorflow
  import sklearn.metrics
  import tempfile
  from deepchem.data import pad_features
  from deepchem.utils.save import log
  from deepchem.models import Model
  from deepchem.nn.copy import Input
  from deepchem.nn.copy import Dense
  from deepchem.nn import model_ops
  from deepchem.models.tf_new_models.graph_topology import merge_dicts
label_desc: Use image node_id 5 for calling the MultitaskGraphClassifier obj's underlying member method code with example usage: obj.add_training_loss(final_loss, logits) and returns: total_loss