How to convert my object detection dataset to Tensorflow COCO format? (i.e. run this Retinanet implementation at my own dataset)

I’m running this Tensorflow implementation of Retinanet (https://keras.io/examples/vision/retinanet/ and it worked for me without problems. However, my goal is to adapt it to my own Object Detection dataset. i.e. put my own object detection dataset to it.

The problem is that the author gets COCO dataset via tfds.load()
I explored these TFRecords files and I noticed that their image annotations are in a different way (different from default COCO annotations) as shown in image below:

Annotation comparison

Is there a way to generate TFRecords files in this specific format of annotations for my own dataset (not get a ready-to-use dataset from tfds)?

Thanks a lot!

colab notebook with the error: https://github.com/allansdefreitas/Deep-Learning-Experiments/blob/master/retinanet_coco_error.ipynb