diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index e601c3b62ff..7a9204200fa 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -812,8 +812,8 @@ genrule(
     }),
     outs = ["__init__.py"],
     cmd = select({
-        "api_version_2": "cp $(@D)/_api/v2/v2.py $(OUTS) && sed -i'.original' 's:from . import:from . _api.v2 import:g' $(OUTS)",
-        "//conditions:default": "cp $(@D)/_api/v1/v1.py $(OUTS) && sed -i'.original' 's:from . import:from ._api.v1 import:g' $(OUTS)",
+        "api_version_2": "cp $(@D)/_api/v2/v2.py $(OUTS)",
+        "//conditions:default": "cp $(@D)/_api/v1/v1.py $(OUTS)",
     }),
 )
 
diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py
index 0aca0756f7d..3d8d92c63e7 100644
--- a/tensorflow/api_template.__init__.py
+++ b/tensorflow/api_template.__init__.py
@@ -78,7 +78,7 @@ except ImportError:
   pass
 
 try:
-  from .python.keras.api._v2 import keras
+  from tensorflow.python.keras.api._v2 import keras
   _current_module.__path__ = (
       [_module_util.get_parent_dir(keras)] + _current_module.__path__)
   setattr(_current_module, "keras", keras)
diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py
index ca2e96d4b2e..2962a7a60e2 100644
--- a/tensorflow/api_template_v1.__init__.py
+++ b/tensorflow/api_template_v1.__init__.py
@@ -69,7 +69,7 @@ except ImportError:
   pass
 
 try:
-  from .python.keras.api._v1 import keras
+  from tensorflow.python.keras.api._v1 import keras
   _current_module.__path__ = (
       [_module_util.get_parent_dir(keras)] + _current_module.__path__)
   setattr(_current_module, "keras", keras)
diff --git a/tensorflow/python/tools/api/generator/create_python_api.py b/tensorflow/python/tools/api/generator/create_python_api.py
index a3949deac4e..98cd159a63f 100644
--- a/tensorflow/python/tools/api/generator/create_python_api.py
+++ b/tensorflow/python/tools/api/generator/create_python_api.py
@@ -195,7 +195,8 @@ class _ModuleInitCodeBuilder(object):
               dest_module_name=parent_module,
               dest_name=module_split[submodule_index])
         else:
-          import_from = '.'
+          if submodule_index > 0:
+            import_from += '.' + '.'.join(module_split[:submodule_index])
           self.add_import(
               symbol=None,
               source_module_name=import_from,
diff --git a/tensorflow/tools/api/tests/module_test.py b/tensorflow/tools/api/tests/module_test.py
index 96bd6d73142..257d558cda7 100644
--- a/tensorflow/tools/api/tests/module_test.py
+++ b/tensorflow/tools/api/tests/module_test.py
@@ -23,7 +23,6 @@ import pkgutil
 
 import tensorflow as tf
 
-from tensorflow.python import tf2
 from tensorflow.python.platform import test
 
 
@@ -51,18 +50,6 @@ class ModuleTest(test.TestCase):
   def testName(self):
     self.assertEqual('tensorflow', tf.__name__)
 
-  def testBuiltInName(self):
-    # range is a built-in name in Python. Just checking that
-    # tf.range works fine.
-    if tf2.enabled():
-      self.assertEqual(
-          'tf.Tensor([1 2 3 4 5 6 7 8 9], shape=(9,), dtype=int32)',
-          str(tf.range(1, 10)))
-    else:
-      self.assertEqual(
-          'Tensor("range:0", shape=(9,), dtype=int32)',
-          str(tf.range(1, 10)))
-
 
 if __name__ == '__main__':
   test.main()