How to convert COCO-segmentation to TFrecord use for TF segment model

How to convert COCO-segmentation to TFrecord use for TF segment model.
For example, my COCO file:“{“info”:{“year”:“2023”,“version”:“1”,“description”:“Exported from roboflow.com”,“contributor”:”“,“url”:“Free Computer Vision Datasets BY 4.0”}],“categories”:[{“id”:0,“name”:“HN”,“supercategory”:“none”},{“id”:1,“name”:“HN”,“supercategory”:“HN”}],“images”:[{“id”:0,“license”:1,“file_name”:“2_jpg.rf.c45cf2248b1aa24c3622ed82c968668e.jpg”,“height”:640,“width”:640,“date_captured”:“2023-10-19T03:52:11+00:00”},{“id”:1,“license”:1,“file_name”:“3_jpg.rf.bb8dceb2e02e403720681d5f8c489779.jpg”,“height”:640,“width”:640,“date_captured”:“2023-10-19T03:52:11+00:00”},{“id”:2,“license”:1,“file_name”:“1_jpg.rf.3134db1ae7daf41dc41b3f84b7c33733.jpg”,“height”:640,“width”:640,“date_captured”:“2023-10-19T03:52:11+00:00”}],“annotations”:[{“id”:0,“image_id”:0,“category_id”:1,“bbox”:[90,81,442.658,502.999],“area”:222656.504,“segmentation”:[[246.822,537.982,319.826,584.311,371.972,582.42,427.594,567.292,479.739,545.546,504.074,499.217,521.456,409.396,526.091,374.413,519.138,345.103,533.044,314.847,516.821,283.646,515.662,227.862,509.868,190.988,504.074,162.624,499.439,119.131,485.533,97.385,383.56,81.312,323.303,86.985,281.586,90.767,244.505,89.821,214.376,86.985,174.977,92.658,132.102,92.658,99.656,101.167,90.386,154.114,114.72,264.736,166.866,379.14,246.822,537.982]],“iscrowd”:0},{“id”:1,“image_id”:1,“category_id”:1,“bbox”:[148,53,356.467,528.775],“area”:188490.937,“segmentation”:[[176.866,379.067,200.57,458.719,227.92,520.138,279.886,561.404,315.442,581.556,361.026,575.798,394.758,561.404,426.667,548.928,452.194,544.13,465.869,513.42,478.632,495.187,489.573,462.558,499.601,418.414,501.425,384.825,504.16,329.165,495.954,294.617,487.749,243.755,486.838,224.561,474.986,151.627,472.251,124.756,415.726,53.741,389.288,52.782,325.47,89.249,304.501,95.966,217.892,67.176,172.308,110.361,147.692,152.587,152.251,233.198,176.866,379.067]],“iscrowd”:0},{“id”:2,“image_id”:2,“category_id”:1,“bbox”:[140,217,430.345,263.409],“area”:113356.896,“segmentation”:[[301.609,473.287,349.425,480.085,404.598,478.386,441.379,451.195,489.195,410.409,492.874,391.715,549.885,344.981,564.598,289.75,570.115,259.161,514.943,217.525,485.517,216.676,395.402,229.421,371.494,234.519,285.057,226.872,246.437,224.323,204.138,232.82,171.034,247.265,139.77,281.253,158.161,359.426,233.563,428.253,301.609,473.287]],“iscrowd”:0}]}”

I recently implemented this conversion using the code I found in this tutorial from Tensorflow Model Garden:
https://github.com/tensorflow/models/blob/master/docs/vision/instance_segmentation.ipynb
Check the function _generate_tf_records.