def learn():
  """Return tf.contrib.learn module or dummy version."""
  if not is_tf2:
    from tensorflow.contrib import learn as contrib_learn  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
    return contrib_learn
  return DummyModule(
      RunConfig=tf_estimator.RunConfig,
      monitors=DummyModule(
          replace_monitors_with_hooks=replace_monitors_with_hooks),
  )
Return tf.contrib.learn module or dummy version.
tensor2tensor/utils/contrib.py