In ArcGIS Pro you can do this:
cim_version = 'V2'
aprx = arcpy.mp.ArcGISProject(aprx_file)
map0 = aprx.listMaps()
lyr0 = map0.listLayers()
def0 = lyr0.getDefinition(cim_version)
# serviceLayerID will be -1 if "allow assign. unique ids to layers"
# was not check on the Data Frame properties
# in that case, serviceLayerID are in order from 0 -&...