from tensorflow.contrib.learn.python.learn.estimators import tensor_signature


  def _check_inputs(self, features, targets):
    if self._features_info is not None:
      if not tensor_signature.tensors_compatible(features, self._features_info):
        raise ValueError('Features are incompatible with given information. '
                         'Given features: %s, required signatures: %s.' %
                         (str(features), str(self._features_info)))
    else:
      self._features_info = tensor_signature.create_signatures(features)
    if self._targets_info is not None:
      if not tensor_signature.tensors_compatible(targets, self._targets_info):
        raise ValueError('Targets are incompatible with given information. '
                         'Given targets: %s, required signatures: %s.' %
                         (str(targets), str(self._targets_info)))
    else:
      self._targets_info = tensor_signature.create_signatures(targets)

  def _train_model(self,
                   input_fn,
                   steps,
                   feed_fn=None,
                   device_fn=None,
                   monitor=None,
                   log_every_steps=100,
                   fail_on_nan_loss=True):
    if self._config.execution_mode not in ('all', 'train'):
      return

    # Stagger startup of worker sessions based on task id.
    sleep_secs = min(self._config.training_worker_max_startup_secs,
