def layers():
  """Return layers module or dummy version."""
  try:
    from tensorflow.contrib import layers as contrib_layers  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
    return contrib_layers
  except:  # pylint: disable=bare-except
    return DummyModule(
        OPTIMIZER_CLS_NAMES={}, optimize_loss=tf_slim.optimize_loss)
Return layers module or dummy version.
tensor2tensor/utils/contrib.py