class_docstr: The base trainer class. Given an object of `hparams`, a trainer
  creates and initializes a model. After initialization, the method
  `model_train` can be used to train the model.
class_docstr_tok: ["The","base","trainer","class",".","Given","an","object","of","`","hparams","`",",","a","trainer","creates","and","initializes","a","model",".","After","initialization",",","the","method","`","model_train","`","can","be","used","to","train","the","model","."]
code: def _build_train_op(self, predictions, y, predictions_adv):
      model = self.model
      hparams = self.hparams
      if hparams.model_type == "resnet_tf":
          build_train_op = model.build_cost
      else:
          raise NotImplementedError(
              "this configuration of this example is no longer maintained"
          )
  
      # Define loss
      with tf.variable_scope("train_loss"):
          if predictions_adv is not None:
              if hparams.only_adv_train:
                  loss = build_train_op(y, predictions_adv)
              else:
                  loss = build_train_op(y, predictions)
                  adv_loss = build_train_op(y, predictions_adv)
                  loss = (loss + adv_loss) / 2
          else:
              loss = build_train_op(y, predictions)
  
      if hparams.model_type == "resnet_tf":
          train_step = model.build_train_op_from_cost(loss)
      else:
          optim = tf.train.AdamOptimizer(learning_rate=hparams.adam_lrn)
          train_step = optim.minimize(loss)
  
      return train_step
  
imports: from collections import OrderedDict
  import logging
  import math
  import time
  import os
  import numpy
  import six
  import tensorflow
  from cleverhans.utils_tf import batch_indices
  from cleverhans.utils_mnist import data_mnist
  import utils_cifar
  import utils_svhn
  from utils import preprocess_batch
  from make_model import make_model
  from evaluator import Evaluator
  from evaluator import create_adv_by_name
  from model import clone_variable
label_desc: Use image node_id 10 for calling the TrainManager obj's underlying member method code with example usage: obj._build_train_op(predictions, y, predictions_adv) and returns: train_step