I think you need to use tf.greather or to wrap your original train_step with tf.function.
See:

  

      stackoverflow.com
  

  
      
    
  


  Tensorflow tf.function conditionals 2



  python, tensorflow



  asked by
  
  
    Joren Boulanger
  
  on 11:31AM - 05 Feb 21 UTC