title: Error importing BERT: module 'tensorflow._api.v2.train' has no attribute 'Optimizer'
body: <p>I tried to use <code>bert-tensorflow</code> in Google Colab, but I got the following error:</p>
  
  <blockquote>
    <p>--------------------------------------------------------------------------- AttributeError                            Traceback (most recent call
    last)  in ()
          1 import  bert
    ----> 2 from bert import run_classifier_with_tfhub # run_classifier
          3 from bert import optimization
          4 from bert import tokenization</p>
    
    <p>1 frames /usr/local/lib/python3.6/dist-packages/bert/optimization.py
    in ()
         85 
         86 
    ---> 87 class AdamWeightDecayOptimizer(tf.train.Optimizer):
         88   """A basic Adam optimizer that includes "correct" L2 weight decay."""
         89 </p>
    
    <p>AttributeError: module 'tensorflow._api.v2.train' has no attribute
    'Optimizer'</p>
  </blockquote>
  
  <p>Here is the code I tried:</p>
  
  <ol>
  <li>Install the libraries:</li>
  </ol>
  
  <p><code>!pip install --upgrade --force-reinstall tensorflow
  !pip install --upgrade --force-reinstall tensorflow-gpu
  !pip install tensorflow_hub
  !pip install sentencepiece
  !pip install bert-tensorflow</code></p>
  
  <ol start="2">
  <li>Run this code:</li>
  </ol>
  
  <p><code>from sklearn.model_selection import train_test_split
  import pandas as pd
  from datetime import datetime
  from tensorflow.keras import optimizers
  import  bert
  from bert import run_classifier
  from bert import optimization
  from bert import tokenization
  </code></p>
  
  <p>I've also tried 
  <code>import tensorflow.compat.v1 as tf
  tf.disable_v2_behavior()</code></p>
  
  <p>But got the same error.</p>