class_docstr: Builds a NASNet subnetwork for AdaNet.
docstr: See `adanet.subnetwork.Builder`.
docstr_tok: ["See","`","adanet.subnetwork.Builder","`","."]
code: def build_subnetwork_train_op(
      self,
      subnetwork,
      loss,
      var_list,
      labels,
      iteration_step,
      summary,
      previous_ensemble,
  ):
      """See `adanet.subnetwork.Builder`."""
  
      del loss  # Loss for training is defined below.
  
      # The AdaNet Estimator is responsible for incrementing the global step.
      optimizer, learning_rate = self._optimizer_fn(
          learning_rate=self._initial_learning_rate
      )
      with tf.name_scope(""):
          summary.scalar(
              "learning_rate/adanet/subnetwork", learning_rate
          )
  
      onehot_labels = tf.one_hot(
          tf.reshape(labels, [-1]),
          subnetwork.logits.shape[-1],
          dtype=tf.int32,
      )
  
      loss = tf.losses.softmax_cross_entropy(
          onehot_labels=onehot_labels,
          logits=subnetwork.logits,
          weights=1.0,
          label_smoothing=self._label_smoothing,
      )
  
      # Add knowledge ditillation loss.
      if previous_ensemble:
          if (
              self._knowledge_distillation
              == KnowledgeDistillation.ADAPTIVE
          ):
              loss += tf.losses.softmax_cross_entropy(
                  onehot_labels=tf.nn.softmax(previous_ensemble.logits),
                  logits=subnetwork.logits,
                  weights=1.0,
                  scope="loss_adaptive_kd",
              )
  
          if (
              self._knowledge_distillation
              == KnowledgeDistillation.BORN_AGAIN
          ):
              loss += tf.losses.softmax_cross_entropy(
                  onehot_labels=tf.nn.softmax(
                      previous_ensemble.weighted_subnetworks[-1].logits
                  ),
                  logits=subnetwork.logits,
                  weights=1.0,
                  scope="loss_born_again_kd",
              )
  
      # Add weight decay.
      loss += tf.losses.get_regularization_loss(scope=self._name_scope)
  
      update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
      with tf.control_dependencies(update_ops):
          if self._hparams.clip_gradients > 0:
              optimizer = tf.contrib.estimator.clip_gradients_by_norm(
                  optimizer, self._hparams.clip_gradients
              )
          return optimizer.minimize(loss, var_list=var_list)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import adanet
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the Builder obj's underlying member method code with example usage: obj.build_subnetwork_train_op(subnetwork, loss, var_list, labels, iteration_step, summary, previous_ensemble) and returns: optimizer