adapted part of the code for saving tf databases as tfrecords and loading them from tf records to tf2.