Have  you tried with:

  
      

      TensorFlow
  

  
    

tf.data.experimental.get_single_element  |  TensorFlow Core v2.5.0 5

  Returns the single element in dataset as a nested structure of tensors.


  

  
    
    
  

  


Or you can use an iterator:
  
      

      TensorFlow
  

  
    

tf.data.Iterator  |  TensorFlow Core v2.5.0 2

  Represents an iterator of a tf.data.Dataset.