Monkey patch tf 1.12 so tfds can use it.

def _patch_for_tf1_12(tf):
  """Monkey patch tf 1.12 so tfds can use it."""
  tf.io.gfile = tf.gfile
  tf.io.gfile.copy = tf.gfile.Copy
  tf.io.gfile.exists = tf.gfile.Exists
  tf.io.gfile.glob = tf.gfile.Glob
  tf.io.gfile.isdir = tf.gfile.IsDirectory
  tf.io.gfile.listdir = tf.gfile.ListDirectory
  tf.io.gfile.makedirs = tf.gfile.MakeDirs
  tf.io.gfile.mkdir = tf.gfile.MkDir
  tf.io.gfile.remove = tf.gfile.Remove
  tf.io.gfile.rename = tf.gfile.Rename
  tf.io.gfile.rmtree = tf.gfile.DeleteRecursively
  tf.io.gfile.stat = tf.gfile.Stat
  tf.io.gfile.walk = tf.gfile.Walk
  tf.io.gfile.GFile = tf.gfile.GFile
  tf.data.experimental = tf.contrib.data
  tf.compat.v1 = types.ModuleType("tf.compat.v1")
  tf.compat.v1.assert_greater = tf.assert_greater
  tf.compat.v1.placeholder = tf.placeholder
  tf.compat.v1.ConfigProto = tf.ConfigProto
  tf.compat.v1.Session = tf.Session
  tf.compat.v1.enable_eager_execution = tf.enable_eager_execution
  tf.compat.v1.io = tf.io
  tf.compat.v1.data = tf.data
  tf.compat.v1.data.Dataset = tf.data.Dataset
  tf.compat.v1.data.make_one_shot_iterator = (
      lambda ds: ds.make_one_shot_iterator())
  tf.compat.v1.train = tf.train
  tf.compat.v1.global_variables_initializer = tf.global_variables_initializer
  tf.compat.v1.test = tf.test
  tf.compat.v1.test.get_temp_dir = tf.test.get_temp_dir
  tf.nest = tf.contrib.framework.nest