class_docstr: Updates the train_time variable.
  
  Optionally stops training if we've passed a time limit.
class_docstr_tok: ["Updates","the","train_time","variable",".","Optionally","stops","training","if","we","'ve","passed","a","time","limit","."]
code: def __init__(self, train_time, time_limit=None):
      super(TrainTimeHook, self).__init__()
      self._train_time = train_time
      self._time_limit = time_limit
      self._increment_amount = tf.placeholder(tf.float32, None)
      self._increment_op = tf.assign_add(
          train_time, self._increment_amount
      )
      self._last_run_duration = None
  
imports: import os
  import time
  from absl import logging
  from magenta.models.gansynth.lib import networks
  import numpy
  import tensorflow.compat.v1
  import tensorflow_gan
label_desc: Use image node_id 1 to create a new TrainTimeHook object from inherited base classes: tf.train with example: obj = TrainTimeHook(train_time, time_limit)