def _get_builtin_metadata(dataset_name):
    if dataset_name == "coco":
        return _get_coco_instances_meta()
    if dataset_name == "coco_panoptic_separated":
        return _get_coco_panoptic_separated_meta()
    elif dataset_name == "coco_panoptic_standard":
        meta = {} # [STATE] meta = {} [/STATE]
        # The following metadata maps contiguous id from [0, #thing categories +
        # #stuff categories) to their names and colors. We have to replica of the
        # same name and color under "thing_*" and "stuff_*" because the current
        # visualization function in D2 handles thing and class classes differently
        # due to some heuristic used in Panoptic FPN. We keep the same naming to
        # enable reusing existing visualization functions.
        thing_classes = [k["name"] for k in COCO_CATEGORIES] # [STATE] thing_classes = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'] [/STATE]
        thing_colors = [k["color"] for k in COCO_CATEGORIES] # [STATE] thing_colors = [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]] [/STATE]
        stuff_classes = [k["name"] for k in COCO_CATEGORIES] # [STATE] stuff_classes = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'] [/STATE]
        stuff_colors = [k["color"] for k in COCO_CATEGORIES] # [STATE] stuff_colors = [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]] [/STATE]

        meta["thing_classes"] = thing_classes # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged']} [/STATE]
        meta["thing_colors"] = thing_colors # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'thing_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]]} [/STATE]
        meta["stuff_classes"] = stuff_classes # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'thing_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'stuff_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged']} [/STATE]
        meta["stuff_colors"] = stuff_colors # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'thing_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'stuff_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'stuff_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]]} [/STATE]

        # Convert category id for training:
        #   category id: like semantic segmentation, it is the class id for each
        #   pixel. Since there are some classes not used in evaluation, the category
        #   id is not always contiguous and thus we have two set of category ids:
        #       - original category id: category id in the original dataset, mainly
        #           used for evaluation.
        #       - contiguous category id: [0, #classes), in order to train the linear
        #           softmax classifier.
        thing_dataset_id_to_contiguous_id = {} # [STATE] thing_dataset_id_to_contiguous_id = {} [/STATE]
        stuff_dataset_id_to_contiguous_id = {} # [STATE] stuff_dataset_id_to_contiguous_id = {} [/STATE]

        for i, cat in enumerate(COCO_CATEGORIES): #  [STATE] i = 0 [/STATE] [STATE] cat = {'color': [220, 20, 60], 'isthing': 1, 'id': 1, 'name': 'person'} [/STATE] [STATE] i = 1 [/STATE] [STATE] cat = {'color': [119, 11, 32], 'isthing': 1, 'id': 2, 'name': 'bicycle'} [/STATE] [STATE] i = 2 [/STATE] [STATE] cat = {'color': [0, 0, 142], 'isthing': 1, 'id': 3, 'name': 'car'} [/STATE] [STATE] i = 3 [/STATE] [STATE] cat = {'color': [0, 0, 230], 'isthing': 1, 'id': 4, 'name': 'motorcycle'} [/STATE] [STATE] i = 4 [/STATE] [STATE] cat = {'color': [106, 0, 228], 'isthing': 1, 'id': 5, 'name': 'airplane'} [/STATE] [STATE] i = 5 [/STATE] [STATE] cat = {'color': [0, 60, 100], 'isthing': 1, 'id': 6, 'name': 'bus'} [/STATE] [STATE] i = 6 [/STATE] [STATE] cat = {'color': [0, 80, 100], 'isthing': 1, 'id': 7, 'name': 'train'} [/STATE] [STATE] i = 7 [/STATE] [STATE] cat = {'color': [0, 0, 70], 'isthing': 1, 'id': 8, 'name': 'truck'} [/STATE] [STATE] i = 8 [/STATE] [STATE] cat = {'color': [0, 0, 192], 'isthing': 1, 'id': 9, 'name': 'boat'} [/STATE] [STATE] i = 9 [/STATE] [STATE] cat = {'color': [250, 170, 30], 'isthing': 1, 'id': 10, 'name': 'traffic light'} [/STATE] [STATE] i = 10 [/STATE]
            if cat["isthing"]:
                thing_dataset_id_to_contiguous_id[cat["id"]] = i #  [STATE] thing_dataset_id_to_contiguous_id = {1: 0} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17, 20: 18} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17, 20: 18, 21: 19} [/STATE] [STATE] thing_dataset_id_to_contiguous_id = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17, 20: 18, 21: 19, 22: 20} [/STATE]
            else:
                stuff_dataset_id_to_contiguous_id[cat["id"]] = i #  [STATE] stuff_dataset_id_to_contiguous_id = {92: 80} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96, 145: 97} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96, 145: 97, 147: 98} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96, 145: 97, 147: 98, 148: 99} [/STATE] [STATE] stuff_dataset_id_to_contiguous_id = {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96, 145: 97, 147: 98, 148: 99, 149: 100} [/STATE]

        meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'thing_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'stuff_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'stuff_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'thing_dataset_id_to_contiguous_id': {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17, 20: 18, 21: 19, 22: 20, 23: 21, 24: 22, 25: 23, 27: 24, 28: 25, 31: 26, 32: 27, 33: 28, 34: 29, 35: 30, 36: 31, 37: 32, 38: 33, 39: 34, 40: 35, 41: 36, 42: 37, 43: 38, 44: 39, 46: 40, 47: 41, 48: 42, 49: 43, 50: 44, 51: 45, 52: 46, 53: 47, 54: 48, 55: 49, 56: 50, 57: 51, 58: 52, 59: 53, 60: 54, 61: 55, 62: 56, 63: 57, 64: 58, 65: 59, 67: 60, 70: 61, 72: 62, 73: 63, 74: 64, 75: 65, 76: 66, 77: 67, 78: 68, 79: 69, 80: 70, 81: 71, 82: 72, 84: 73, 85: 74, 86: 75, 87: 76, 88: 77, 89: 78, 90: 79}} [/STATE]
        meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id # [STATE] meta = {'thing_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'thing_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'stuff_classes': ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skatebo...rigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush', 'banner', 'blanket', 'bridge', 'cardboard', 'counter', 'curtain', 'door-stuff', 'floor-wood', 'flower', 'fruit', 'gravel', 'house', 'light', 'mirror-stuff', 'net', 'pillow', 'platform', 'playingfield', 'railroad', 'river', 'road', 'roof', 'sand', 'sea', 'shelf', 'snow', 'stairs', 'tent', 'towel', 'wall-brick', 'wall-stone', 'wall-tile', 'wall-wood', 'water-other', 'window-blind', 'window-other', 'tree-merged', 'fence-merged', 'ceiling-merged', 'sky-other-merged', 'cabinet-merged', 'table-merged', 'floor-other-merged', 'pavement-merged', 'mountain-merged', 'grass-merged', 'dirt-merged', 'paper-merged', 'food-other-merged', 'building-other-merged', 'rock-merged', 'wall-other-merged', 'rug-merged'], 'stuff_colors': [[220, 20, 60], [119, 11, 32], [0, 0, 142], [0, 0, 230], [106, 0, 228], [0, 60, 100], [0, 80, 100], [0, 0, 70], [0, 0, 192], [250, 170, 30], [100, 170, 30], [220, 220, 0], [175, 116, 175], [250, 0, 30], [165, 42, 42], [255, 77, 255], [0, 226, 252], [182, 182, 255], [0, 82, 0], [120, 166, 157], [110, 76, 0], [174, 57, 255], [199, 100, 0], [72, 0, 118], [255, 179, 240], [0, 125, 92], [209, 0, 151], [188, 208, 182], [0, 220, 176], [255, 99, 164], [92, 0, 73], [133, 129, 255], [78, 180, 255], [0, 228, 0], [174, 255, 243], [45, 89, 255], [134, 134, 103], [145, 148, 174], [255, 208, 186], [197, 226, 255], [171, 134, 1], [109, 63, 54], [207, 138, 255], [151, 0, 95], [9, 80, 61], [84, 105, 51], [74, 65, 105], [166, 196, 102], [208, 195, 210], [255, 109, 65], [0, 143, 149], [179, 0, 194], [209, 99, 106], [5, 121, 0], [227, 255, 205], [147, 186, 208], [153, 69, 1], [3, 95, 161], [163, 255, 0], [119, 0, 170], [0, 182, 199], [0, 165, 120], [183, 130, 88], [95, 32, 0], [130, 114, 135], [110, 129, 133], [166, 74, 118], [219, 142, 185], [79, 210, 114], [178, 90, 62], [65, 70, 15], [127, 167, 115], [59, 105, 106], [142, 108, 45], [196, 172, 0], [95, 54, 80], [128, 76, 255], [201, 57, 1], [246, 0, 122], [191, 162, 208], [255, 255, 128], [147, 211, 203], [150, 100, 100], [168, 171, 172], [146, 112, 198], [210, 170, 100], [92, 136, 89], [218, 88, 184], [241, 129, 0], [217, 17, 255], [124, 74, 181], [70, 70, 70], [255, 228, 255], [154, 208, 0], [193, 0, 92], [76, 91, 113], [255, 180, 195], [106, 154, 176], [230, 150, 140], [60, 143, 255], [128, 64, 128], [92, 82, 55], [254, 212, 124], [73, 77, 174], [255, 160, 98], [255, 255, 255], [104, 84, 109], [169, 164, 131], [225, 199, 255], [137, 54, 74], [135, 158, 223], [7, 246, 231], [107, 255, 200], [58, 41, 149], [183, 121, 142], [255, 73, 97], [107, 142, 35], [190, 153, 153], [146, 139, 141], [70, 130, 180], [134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96], [64, 170, 64], [152, 251, 152], [208, 229, 228], [206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143], [102, 102, 156], [250, 141, 255]], 'thing_dataset_id_to_contiguous_id': {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15, 18: 16, 19: 17, 20: 18, 21: 19, 22: 20, 23: 21, 24: 22, 25: 23, 27: 24, 28: 25, 31: 26, 32: 27, 33: 28, 34: 29, 35: 30, 36: 31, 37: 32, 38: 33, 39: 34, 40: 35, 41: 36, 42: 37, 43: 38, 44: 39, 46: 40, 47: 41, 48: 42, 49: 43, 50: 44, 51: 45, 52: 46, 53: 47, 54: 48, 55: 49, 56: 50, 57: 51, 58: 52, 59: 53, 60: 54, 61: 55, 62: 56, 63: 57, 64: 58, 65: 59, 67: 60, 70: 61, 72: 62, 73: 63, 74: 64, 75: 65, 76: 66, 77: 67, 78: 68, 79: 69, 80: 70, 81: 71, 82: 72, 84: 73, 85: 74, 86: 75, 87: 76, 88: 77, 89: 78, 90: 79}, 'stuff_dataset_id_to_contiguous_id': {92: 80, 93: 81, 95: 82, 100: 83, 107: 84, 109: 85, 112: 86, 118: 87, 119: 88, 122: 89, 125: 90, 128: 91, 130: 92, 133: 93, 138: 94, 141: 95, 144: 96, 145: 97, 147: 98, 148: 99, 149: 100, 151: 101, 154: 102, 155: 103, 156: 104, 159: 105, 161: 106, 166: 107, 168: 108, 171: 109, 175: 110, 176: 111, 177: 112, 178: 113, 180: 114, 181: 115, 184: 116, 185: 117, 186: 118, 187: 119, 188: 120, 189: 121, 190: 122, 191: 123, 192: 124, 193: 125, 194: 126, 195: 127, 196: 128, 197: 129, 198: 130, 199: 131, 200: 132}} [/STATE]

        return meta
    elif dataset_name == "coco_person":
        return {
            "thing_classes": ["person"],
            "keypoint_names": COCO_PERSON_KEYPOINT_NAMES,
            "keypoint_flip_map": COCO_PERSON_KEYPOINT_FLIP_MAP,
            "keypoint_connection_rules": KEYPOINT_CONNECTION_RULES,
        }
    elif dataset_name == "cityscapes":
        # fmt: off
        CITYSCAPES_THING_CLASSES = [
            "person", "rider", "car", "truck",
            "bus", "train", "motorcycle", "bicycle",
        ]
        CITYSCAPES_STUFF_CLASSES = [
            "road", "sidewalk", "building", "wall", "fence", "pole", "traffic light",
            "traffic sign", "vegetation", "terrain", "sky", "person", "rider", "car",
            "truck", "bus", "train", "motorcycle", "bicycle",
        ]
        # fmt: on
        return {
            "thing_classes": CITYSCAPES_THING_CLASSES,
            "stuff_classes": CITYSCAPES_STUFF_CLASSES,
        }
    raise KeyError("No built-in metadata for dataset {}".format(dataset_name))

_get_builtin_metadata('coco_panoptic_standard')

1: def _get_builtin_metadata(dataset_name):
2:     if dataset_name == "coco":
3:         return _get_coco_instances_meta()
4:     if dataset_name == "coco_panoptic_separated":
5:         return _get_coco_panoptic_separated_meta()
6:     elif dataset_name == "coco_panoptic_standard":
7:         meta = {}
8:         # The following metadata maps contiguous id from [0, #thing categories +
9:         # #stuff categories) to their names and colors. We have to replica of the
10:         # same name and color under "thing_*" and "stuff_*" because the current
11:         # visualization function in D2 handles thing and class classes differently
12:         # due to some heuristic used in Panoptic FPN. We keep the same naming to
13:         # enable reusing existing visualization functions.
14:         thing_classes = [k["name"] for k in COCO_CATEGORIES]
15:         thing_colors = [k["color"] for k in COCO_CATEGORIES]
16:         stuff_classes = [k["name"] for k in COCO_CATEGORIES]
17:         stuff_colors = [k["color"] for k in COCO_CATEGORIES]
18:
19:         meta["thing_classes"] = thing_classes
20:         meta["thing_colors"] = thing_colors
21:         meta["stuff_classes"] = stuff_classes
22:         meta["stuff_colors"] = stuff_colors
23:
24:         # Convert category id for training:
25:         #   category id: like semantic segmentation, it is the class id for each
26:         #   pixel. Since there are some classes not used in evaluation, the category
27:         #   id is not always contiguous and thus we have two set of category ids:
28:         #       - original category id: category id in the original dataset, mainly
29:         #           used for evaluation.
30:         #       - contiguous category id: [0, #classes), in order to train the linear
31:         #           softmax classifier.
32:         thing_dataset_id_to_contiguous_id = {}
33:         stuff_dataset_id_to_contiguous_id = {}
34:
35:         for i, cat in enumerate(COCO_CATEGORIES):
36:             if cat["isthing"]:
37:                 thing_dataset_id_to_contiguous_id[cat["id"]] = i
38:             else:
39:                 stuff_dataset_id_to_contiguous_id[cat["id"]] = i
40:
41:         meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
42:         meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
43:
44:         return meta
45:     elif dataset_name == "coco_person":
46:         return {
47:             "thing_classes": ["person"],
48:             "keypoint_names": COCO_PERSON_KEYPOINT_NAMES,
49:             "keypoint_flip_map": COCO_PERSON_KEYPOINT_FLIP_MAP,
50:             "keypoint_connection_rules": KEYPOINT_CONNECTION_RULES,
51:         }
52:     elif dataset_name == "cityscapes":
53:         # fmt: off
54:         CITYSCAPES_THING_CLASSES = [
55:             "person", "rider", "car", "truck",
56:             "bus", "train", "motorcycle", "bicycle",
57:         ]
58:         CITYSCAPES_STUFF_CLASSES = [
59:             "road", "sidewalk", "building", "wall", "fence", "pole", "traffic light",
60:             "traffic sign", "vegetation", "terrain", "sky", "person", "rider", "car",
61:             "truck", "bus", "train", "motorcycle", "bicycle",
62:         ]
63:         # fmt: on
64:         return {
65:             "thing_classes": CITYSCAPES_THING_CLASSES,
66:             "stuff_classes": CITYSCAPES_STUFF_CLASSES,
67:         }
68:     raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
69:
70: _get_builtin_metadata('coco_panoptic_standard')

Question: What is the value of ' thing_dataset_id_to_contiguous_id ' in line '37' after '12' th iteration when '_get_builtin_metadata('coco_panoptic_standard')' is executed?

Answer: {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 13: 11}


def wrap_text(text, width):
        """
        Wrap text paragraphs to the given character width while preserving
        newlines.
        """
        out = [] # [STATE] out = [] [/STATE]
        for paragraph in text.splitlines(): #  [STATE] paragraph = 'four score' [/STATE] [STATE] paragraph = 'and seven' [/STATE] [STATE] paragraph = '' [/STATE]
            # Wrap returns an empty list when paragraph is a newline. In order
            # to preserve newlines we substitute a list containing an empty
            # string.
            lines = wrap(paragraph, width=width) or [''] #  [STATE] lines = ['four', 'score'] [/STATE] [STATE] lines = ['and', 'seven'] [/STATE] [STATE] lines = [''] [/STATE]
            out.extend(lines) #  [STATE] out = ['four', 'score'] [/STATE] [STATE] out = ['four', 'score', 'and', 'seven'] [/STATE] [STATE] out = ['four', 'score', 'and', 'seven', ''] [/STATE]
        return out

wrap_text('four score\nand seven\n\n', 6)

1: def wrap_text(text, width):
2:         """
3:         Wrap text paragraphs to the given character width while preserving
4:         newlines.
5:         """
6:         out = []
7:         for paragraph in text.splitlines():
8:             # Wrap returns an empty list when paragraph is a newline. In order
9:             # to preserve newlines we substitute a list containing an empty
10:             # string.
11:             lines = wrap(paragraph, width=width) or ['']
12:             out.extend(lines)
13:         return out
14:
15: wrap_text('four score\nand seven\n\n', 6)

Question: What is the value of ' lines ' in line '11' after '2' th iteration when 'wrap_text('four score\nand seven\n\n', 6)' is executed?

Answer: ['and', 'seven']


def prefixLinesAfterFirst(prefix, s):
    lines = s.splitlines(True) # [STATE] lines = ["'line1\n", "line2'"] [/STATE]

    for i in range(1, len(lines)): #  [STATE] i = 1 [/STATE]
        lines[i] = prefix + lines[i] # [STATE] lines = ["'line1\n", " line2'"] [/STATE]

    return ''.join(lines)

prefixLinesAfterFirst(' ', "'line1\nline2'")

1: def prefixLinesAfterFirst(prefix, s):
2:     lines = s.splitlines(True)
3:
4:     for i in range(1, len(lines)):
5:         lines[i] = prefix + lines[i]
6:
7:     return ''.join(lines)
8:
9: prefixLinesAfterFirst(' ', "'line1\nline2'")

Question: What is the value of ' lines ' in line '5' after '1' th iteration when 'prefixLinesAfterFirst(' ', "'line1\nline2'")' is executed?

Answer: ["'line1\n", " line2'"]


def find_csv_separators(csv):
    """Finds column and decimal separators in a CSV string

    Args:
        csv: CSV text data

    Returns:
        (column_separator, decimal separator)
    """
    lines = csv.strip().split('\n') # [STATE] lines = ['frequency,raw', '20,0', '1000,3', '20000,0'] [/STATE]
    # First find all potential column separators by checking which characters appear on each line that starts with digit
    column_separator_candidates = {',', ';', '\t', '|'} # [STATE] column_separator_candidates = {'\t', ';', ',', '|'} [/STATE]
    for line in lines: #  [STATE] line = 'frequency,raw' [/STATE] [STATE] line = '20,0' [/STATE] [STATE] line = '1000,3' [/STATE] [STATE] line = '20000,0' [/STATE]
        if not numeric_start.match(line):  # Skip rows which don't start with numbers
            continue
        remove_candidates = [] #  [STATE] remove_candidates = [] [/STATE]
        for column_separator in column_separator_candidates: #  [STATE] column_separator = '\t' [/STATE] [STATE] column_separator = ';' [/STATE] [STATE] column_separator = ',' [/STATE] [STATE] column_separator = '|' [/STATE]
            if column_separator not in line:
                # Numeric line doesn't contain the column separator candidate, eliminate the candidate
                remove_candidates.append(column_separator) #  [STATE] remove_candidates = ['\t'] [/STATE] [STATE] remove_candidates = ['\t', ';'] [/STATE] [STATE] remove_candidates = ['\t', ';', '|'] [/STATE]
        for remove_candidate in remove_candidates: #  [STATE] remove_candidate = '\t' [/STATE] [STATE] remove_candidate = ';' [/STATE] [STATE] remove_candidate = '|' [/STATE]
            column_separator_candidates.remove(remove_candidate) #  [STATE] column_separator_candidates = {';', ',', '|'} [/STATE] [STATE] column_separator_candidates = {',', '|'} [/STATE] [STATE] column_separator_candidates = {','} [/STATE]

    if len(column_separator_candidates) == 0:
        raise CsvParseError('Could not find column and decimal separators')

    if column_separator_candidates == {','}:
        # Only comma found, it must be the column separator and decimal point must be dot
        return [',', '.']

    if ',' in column_separator_candidates:
        # Comma is included in the candidates (along with something else), it must be the decimal separator
        decimal_separator = ','
        column_separator_candidates.remove(',')
    else:
        decimal_separator = '.'

    if len(column_separator_candidates) > 1:
        raise CsvParseError(f'Found multiple potential column separators: {column_separator_candidates}')

    return list(column_separator_candidates)[0], decimal_separator

find_csv_separators('frequency,raw\n20,0\n1000,3\n20000,0\n')

1: def find_csv_separators(csv):
2:     """Finds column and decimal separators in a CSV string
3:
4:     Args:
5:         csv: CSV text data
6:
7:     Returns:
8:         (column_separator, decimal separator)
9:     """
10:     lines = csv.strip().split('\n')
11:     # First find all potential column separators by checking which characters appear on each line that starts with digit
12:     column_separator_candidates = {',', ';', '\t', '|'}
13:     for line in lines:
14:         if not numeric_start.match(line):  # Skip rows which don't start with numbers
15:             continue
16:         remove_candidates = []
17:         for column_separator in column_separator_candidates:
18:             if column_separator not in line:
19:                 # Numeric line doesn't contain the column separator candidate, eliminate the candidate
20:                 remove_candidates.append(column_separator)
21:         for remove_candidate in remove_candidates:
22:             column_separator_candidates.remove(remove_candidate)
23:
24:     if len(column_separator_candidates) == 0:
25:         raise CsvParseError('Could not find column and decimal separators')
26:
27:     if column_separator_candidates == {','}:
28:         # Only comma found, it must be the column separator and decimal point must be dot
29:         return [',', '.']
30:
31:     if ',' in column_separator_candidates:
32:         # Comma is included in the candidates (along with something else), it must be the decimal separator
33:         decimal_separator = ','
34:         column_separator_candidates.remove(',')
35:     else:
36:         decimal_separator = '.'
37:
38:     if len(column_separator_candidates) > 1:
39:         raise CsvParseError(f'Found multiple potential column separators: {column_separator_candidates}')
40:
41:     return list(column_separator_candidates)[0], decimal_separator
42:
43: find_csv_separators('frequency,raw\n20,0\n1000,3\n20000,0\n')

Question: What is the value of ' remove_candidates ' in line '16' after '1' th iteration when 'find_csv_separators('frequency,raw\n20,0\n1000,3\n20000,0\n')' is executed?


def find_csv_columns(csv, column_separator):
    lines = csv.strip().split('\n') # [STATE] lines = ['20.000\t68.334\t0', '20.250\t68.335\t0', '19998.498\t27.402\t0'] [/STATE]
    numeric_lines = [line for line in lines if column_separator in line and numeric_start.search(line)] # [STATE] numeric_lines = ['20.000\t68.334\t0', '20.250\t68.335\t0', '19998.498\t27.402\t0'] [/STATE]
    n_columns = list(set([len(line.split(column_separator)) for line in numeric_lines])) # [STATE] n_columns = [3] [/STATE]
    if len(n_columns) != 1:
        raise CsvParseError('Numeric lines have different number of columns')
    n_columns = n_columns[0] # [STATE] n_columns = 3 [/STATE]
    for line in lines: #  [STATE] line = '20.000\t68.334\t0' [/STATE] [STATE] line = '20.250\t68.335\t0' [/STATE] [STATE] line = '19998.498\t27.402\t0' [/STATE]
        if not numeric_start.search(line) and len(line.split(column_separator)) == n_columns:
            return [cell.strip() for cell in line.split(column_separator)]

find_csv_columns('20.000\t68.334\t0\n20.250\t68.335\t0\n19998.498\t27.402\t0', '\t')

1: def find_csv_columns(csv, column_separator):
2:     lines = csv.strip().split('\n')
3:     numeric_lines = [line for line in lines if column_separator in line and numeric_start.search(line)]
4:     n_columns = list(set([len(line.split(column_separator)) for line in numeric_lines]))
5:     if len(n_columns) != 1:
6:         raise CsvParseError('Numeric lines have different number of columns')
7:     n_columns = n_columns[0]
8:     for line in lines:
9:         if not numeric_start.search(line) and len(line.split(column_separator)) == n_columns:
10:             return [cell.strip() for cell in line.split(column_separator)]
11:
12: find_csv_columns('20.000\t68.334\t0\n20.250\t68.335\t0\n19998.498\t27.402\t0', '\t')

Question: What is the value of ' line ' in line '8' after '3' th iteration when 'find_csv_columns('20.000\t68.334\t0\n20.250\t68.335\t0\n19998.498\t27.402\t0', '\t')' is executed?

Answer: '19998.498\t27.402\t0'


def is_sorted(a):
    if len(a) <= 1:
        return True
    for i in range(1, len(a)): #  [STATE] i = 1 [/STATE] [STATE] i = 2 [/STATE] [STATE] i = 3 [/STATE] [STATE] i = 4 [/STATE]
        if less(a[i], a[i - 1]):
            return False
    return True

is_sorted([1, 2, 13, 22, 123])

1: def is_sorted(a):
2:     if len(a) <= 1:
3:         return True
4:     for i in range(1, len(a)):
5:         if less(a[i], a[i - 1]):
6:             return False
7:     return True
8:
9: is_sorted([1, 2, 13, 22, 123])

Question: What is the value of ' i ' in line '4' after '4' th iteration when 'is_sorted([1, 2, 13, 22, 123])' is executed?

Answer: 4


Question: What is the value of ' aux ' in line '6' after '7' th iteration when '_merge([1, 2, 4, 4, 5, 6, 7, 23, 8, 9, 20, 11, 13, 34, 66], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 3, 7)' is executed?

Answer: [1, 2, 4, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0]


def _copy(src, dst, src_is_storage, dst_is_storage):
    """
    Copies file from source to destination

    Args:
        src (str or file-like object): Source file.
        dst (str or file-like object): Destination file.
        src_is_storage (bool): Source is storage.
        dst_is_storage (bool): Destination is storage.
    """
    # If both storage: Tries to perform same storage direct copy
    if src_is_storage and dst_is_storage:
        system = get_instance(src)
        if system is get_instance(dst):

            # Checks if same file
            if system.relpath(src) == system.relpath(dst):
                raise same_file_error(
                    "'%s' and '%s' are the same file" % (src, dst))

            # Tries to copy
            try:
                return system.copy(src, dst)
            except (UnsupportedOperation, ObjectException):
                pass

    # At least one storage object: copies streams
    with cos_open(src, 'rb') as fsrc: # [STATE] fsrc = {} [/STATE]
        with cos_open(dst, 'wb') as fdst: # [STATE] fdst = <_io.BufferedWriter name='/tmp/pytest-of-XXX/pytest-198/test_cos_open0/file_dst.txt'> [/STATE]

            # Get stream buffer size
            for stream in (fdst, fsrc): #  [STATE] stream = <_io.BufferedWriter name='/tmp/pytest-of-XXX/pytest-198/test_cos_open0/file_dst.txt'> [/STATE] [STATE] stream = {} [/STATE]
                try:
                    buffer_size = getattr(stream, '_buffer_size') #  [STATE] E [/STATE] [STATE] X [/STATE] [STATE] C [/STATE] [STATE] E [/STATE] [STATE] P [/STATE] [STATE] T [/STATE] [STATE] I [/STATE] [STATE] O [/STATE] [STATE] N [/STATE] [STATE] : [/STATE] [STATE]   [/STATE] [STATE] A [/STATE] [STATE] t [/STATE] [STATE] t [/STATE] [STATE] r [/STATE] [STATE] i [/STATE] [STATE] b [/STATE] [STATE] u [/STATE] [STATE] t [/STATE] [STATE] e [/STATE] [STATE] E [/STATE]
                    break
                except AttributeError:
                    continue
            else:
                buffer_size = 16384 # [STATE] buffer_size = 16384 [/STATE]

            # Read and write
            copyfileobj(fsrc, fdst, buffer_size)

_copy('dummy_read://file.txt', '/tmp/pytest-of-XXX/pytest-198/test_cos_open0/file_dst.txt', True, False)

1: def _copy(src, dst, src_is_storage, dst_is_storage):
2:     """
3:     Copies file from source to destination
4:
5:     Args:
6:         src (str or file-like object): Source file.
7:         dst (str or file-like object): Destination file.
8:         src_is_storage (bool): Source is storage.
9:         dst_is_storage (bool): Destination is storage.
10:     """
11:     # If both storage: Tries to perform same storage direct copy
12:     if src_is_storage and dst_is_storage:
13:         system = get_instance(src)
14:         if system is get_instance(dst):
15:
16:             # Checks if same file
17:             if system.relpath(src) == system.relpath(dst):
18:                 raise same_file_error(
19:                     "'%s' and '%s' are the same file" % (src, dst))
20:
21:             # Tries to copy
22:             try:
23:                 return system.copy(src, dst)
24:             except (UnsupportedOperation, ObjectException):
25:                 pass
26:
27:     # At least one storage object: copies streams
28:     with cos_open(src, 'rb') as fsrc:
29:         with cos_open(dst, 'wb') as fdst:
30:
31:             # Get stream buffer size
32:             for stream in (fdst, fsrc):
33:                 try:
34:                     buffer_size = getattr(stream, '_buffer_size')
35:                     break
36:                 except AttributeError:
37:                     continue
38:             else:
39:                 buffer_size = 16384
40:
41:             # Read and write
42:             copyfileobj(fsrc, fdst, buffer_size)
43:
44: _copy('dummy_read://file.txt', '/tmp/pytest-of-XXX/pytest-198/test_cos_open0/file_dst.txt', True, False)

Question: What is the value of the variable in line '34' after '1' th iteration when '_copy('dummy_read://file.txt', '/tmp/pytest-of-XXX/pytest-198/test_cos_open0/file_dst.txt', True, False)' is executed?

Answer: E


def get_bound(pts: Iterable[Point]) -> Rect:
    """Compute a minimal rectangle that covers all the points."""
    limit: Rect = (INF, INF, -INF, -INF) # [STATE] limit = (2147483647, 2147483647, -2147483647, -2147483647) [/STATE]
    (x0, y0, x1, y1) = limit # [STATE] x0 = 2147483647 [/STATE] # [STATE] y0 = 2147483647 [/STATE] # [STATE] x1 = -2147483647 [/STATE] # [STATE] y1 = -2147483647 [/STATE]
    for (x, y) in pts: #  [STATE] x = 6 [/STATE] [STATE] y = 7 [/STATE] [STATE] x = 7 [/STATE]
        x0 = min(x0, x) #  [STATE] x0 = 6 [/STATE]
        y0 = min(y0, y) #  [STATE] y0 = 7 [/STATE]
        x1 = max(x1, x) #  [STATE] x1 = 6 [/STATE] [STATE] x1 = 7 [/STATE]
        y1 = max(y1, y) #  [STATE] y1 = 7 [/STATE]
    return x0, y0, x1, y1

get_bound([(6, 7), (7, 7)])

1: def get_bound(pts: Iterable[Point]) -> Rect:
2:     """Compute a minimal rectangle that covers all the points."""
3:     limit: Rect = (INF, INF, -INF, -INF)
4:     (x0, y0, x1, y1) = limit
5:     for (x, y) in pts:
6:         x0 = min(x0, x)
7:         y0 = min(y0, y)
8:         x1 = max(x1, x)
9:         y1 = max(y1, y)
10:     return x0, y0, x1, y1
11:
12: get_bound([(6, 7), (7, 7)])

Question: What is the value of ' x0 ' in line '6' after '1' th iteration when 'get_bound([(6, 7), (7, 7)])' is executed?

Answer: 6


def make_default_short_help(help, max_length=45):
    words = help.split() # [STATE] words = ['Hello', 'World!'] [/STATE]
    total_length = 0 # [STATE] total_length = 0 [/STATE]
    result = [] # [STATE] result = [] [/STATE]
    done = False # [STATE] done = False [/STATE]

    for word in words: #  [STATE] word = 'Hello' [/STATE] [STATE] word = 'World!' [/STATE]
        if word[-1:] == '.':
            done = True
        new_length = result and 1 + len(word) or len(word) #  [STATE] new_length = 5 [/STATE] [STATE] new_length = 7 [/STATE]
        if total_length + new_length > max_length:
            result.append('...')
            done = True
        else:
            if result:
                result.append(' ') # [STATE] result = ['Hello', ' '] [/STATE]
            result.append(word) #  [STATE] result = ['Hello'] [/STATE] [STATE] result = ['Hello', ' ', 'World!'] [/STATE]
        if done:
            break
        total_length += new_length #  [STATE] total_length = 5 [/STATE] [STATE] total_length = 12 [/STATE]

    return ''.join(result)

make_default_short_help('Hello World!', 45)

1: def make_default_short_help(help, max_length=45):
2:     words = help.split()
3:     total_length = 0
4:     result = []
5:     done = False
6:
7:     for word in words:
8:         if word[-1:] == '.':
9:             done = True
10:         new_length = result and 1 + len(word) or len(word)
11:         if total_length + new_length > max_length:
12:             result.append('...')
13:             done = True
14:         else:
15:             if result:
16:                 result.append(' ')
17:             result.append(word)
18:         if done:
19:             break
20:         total_length += new_length
21:
22:     return ''.join(result)
23:
24: make_default_short_help('Hello World!', 45)

Question: What is the value of ' new_length ' in line '10' after '1' th iteration when 'make_default_short_help('Hello World!', 45)' is executed?

Answer: 5


def join_options(options):
    """Given a list of option strings this joins them in the most appropriate
    way and returns them in the form ``(formatted_string,
    any_prefix_is_slash)`` where the second item in the tuple is a flag that
    indicates if any of the option prefixes was a slash.
    """
    rv = [] # [STATE] rv = [] [/STATE]
    any_prefix_is_slash = False # [STATE] any_prefix_is_slash = False [/STATE]
    for opt in options: #  [STATE] opt = '--help' [/STATE]
        prefix = split_opt(opt)[0] # [STATE] prefix = '--' [/STATE]
        if prefix == '/':
            any_prefix_is_slash = True
        rv.append((len(prefix), opt)) # [STATE] rv = [(2, '--help')] [/STATE]

    rv.sort(key=lambda x: x[0])

    rv = ', '.join(x[1] for x in rv) # [STATE] rv = '--help' [/STATE]
    return rv, any_prefix_is_slash

join_options(['--help'])

1: def join_options(options):
2:     """Given a list of option strings this joins them in the most appropriate
3:     way and returns them in the form ``(formatted_string,
4:     any_prefix_is_slash)`` where the second item in the tuple is a flag that
5:     indicates if any of the option prefixes was a slash.
6:     """
7:     rv = []
8:     any_prefix_is_slash = False
9:     for opt in options:
10:         prefix = split_opt(opt)[0]
11:         if prefix == '/':
12:             any_prefix_is_slash = True
13:         rv.append((len(prefix), opt))
14:
15:     rv.sort(key=lambda x: x[0])
16:
17:     rv = ', '.join(x[1] for x in rv)
18:     return rv, any_prefix_is_slash
19:
20: join_options(['--help'])

Question: What is the value of ' prefix ' in line '10' after '1' th iteration when 'join_options(['--help'])' is executed?


def measure_table(rows):
    widths = {} # [STATE] widths = {} [/STATE]
    for row in rows: #  [STATE] row = ('--help', 'Show this message and exit.') [/STATE]
        for idx, col in enumerate(row): #  [STATE] idx = 0 [/STATE] [STATE] col = '--help' [/STATE] [STATE] idx = 1 [/STATE] [STATE] col = 'Show this message and exit.' [/STATE]
            widths[idx] = max(widths.get(idx, 0), term_len(col)) #  [STATE] widths = {0: 6} [/STATE] [STATE] widths = {0: 6, 1: 27} [/STATE]
    return tuple(y for x, y in sorted(widths.items()))

measure_table([('--help', 'Show this message and exit.')])

1: def measure_table(rows):
2:     widths = {}
3:     for row in rows:
4:         for idx, col in enumerate(row):
5:             widths[idx] = max(widths.get(idx, 0), term_len(col))
6:     return tuple(y for x, y in sorted(widths.items()))
7:
8: measure_table([('--help', 'Show this message and exit.')])

Question: What is the value of ' widths ' in line '5' after '2' th iteration when 'measure_table([('--help', 'Show this message and exit.')])' is executed?

Answer: {0: 6, 1: 27}


def encode_request(*args):
    """Pack a series of arguments into a RESP array of bulk strings."""
    result = ["*" + str(len(args)) + CRLF] # [STATE] result = ['*1\r\n'] [/STATE]

    for arg in args: #  [STATE] arg = 'ping' [/STATE]
        if arg is None:
            result.append('$-1' + CRLF)
        else:
            s = str(arg) # [STATE] s = 'ping' [/STATE]
            result.append('$' + str(len(s)) + CRLF + s + CRLF) # [STATE] result = ['*1\r\n', '$4\r\nping\r\n'] [/STATE]

    return "".join(result)

encode_request(('ping',))

1: def encode_request(*args):
2:     """Pack a series of arguments into a RESP array of bulk strings."""
3:     result = ["*" + str(len(args)) + CRLF]
4:
5:     for arg in args:
6:         if arg is None:
7:             result.append('$-1' + CRLF)
8:         else:
9:             s = str(arg)
10:             result.append('$' + str(len(s)) + CRLF + s + CRLF)
11:
12:     return "".join(result)
13:
14: encode_request(('ping',))

Question: What is the value of ' s ' in line '9' after '1' th iteration when 'encode_request(('ping',))' is executed?

Answer: 'ping'


def parse_array(data, start=0):
    endcnt = data.find(CRLF, start + 1) # [STATE] endcnt = 2 [/STATE]

    if endcnt == -1:
        raise ParseError("Unterminated array element count after pos {}.".format(start + 1))

    try:
        count = int(data[start + 1:endcnt]) # [STATE] count = 3 [/STATE]
    except (ValueError, TypeError):
        raise ParseError("Invalid array element count at pos {} - {}.".format(start + 1, endcnt))

    start = endcnt + CRLFLEN # [STATE] start = 4 [/STATE]

    if count == -1:
        return None, endcnt

    result = [] # [STATE] result = [] [/STATE]

    for i in range(count): #  [STATE] i = 0 [/STATE] [STATE] i = 1 [/STATE] [STATE] i = 2 [/STATE]
        if start + 4 < len(data):
            obj, start = _decode(data, start) #  [STATE] obj = 'SET' [/STATE] [STATE] start = 13 [/STATE] [STATE] start = 35 [/STATE] [STATE] obj = 'memtier-8232902' [/STATE] [STATE] start = 43 [/STATE] [STATE] obj = 'xx' [/STATE]
            result.append(obj) #  [STATE] result = ['SET'] [/STATE] [STATE] result = ['SET', 'memtier-8232902'] [/STATE] [STATE] result = ['SET', 'memtier-8232902', 'xx'] [/STATE]
        else:
            raise ParseError("Unterminated array element at pos {}".format(start))

    return result, start

parse_array('*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n', 0)

1: def parse_array(data, start=0):
2:     endcnt = data.find(CRLF, start + 1)
3:
4:     if endcnt == -1:
5:         raise ParseError("Unterminated array element count after pos {}.".format(start + 1))
6:
7:     try:
8:         count = int(data[start + 1:endcnt])
9:     except (ValueError, TypeError):
10:         raise ParseError("Invalid array element count at pos {} - {}.".format(start + 1, endcnt))
11:
12:     start = endcnt + CRLFLEN
13:
14:     if count == -1:
15:         return None, endcnt
16:
17:     result = []
18:
19:     for i in range(count):
20:         if start + 4 < len(data):
21:             obj, start = _decode(data, start)
22:             result.append(obj)
23:         else:
24:             raise ParseError("Unterminated array element at pos {}".format(start))
25:
26:     return result, start
27:
28: parse_array('*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n', 0)

Question: What is the value of ' start ' in line '21' after '2' th iteration when 'parse_array('*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n', 0)' is executed?

Answer: 13


def strip(tokens):
        output = "" # [STATE] output = '' [/STATE]
        for type_, value in tokens: #  [STATE] type_ = 1 [/STATE] [STATE] value = '' [/STATE] [STATE] value = '{message}' [/STATE] [STATE] value = '\n' [/STATE] [STATE] value = '{exception}' [/STATE]
            if type_ == TokenType.TEXT:
                output += value #  [STATE] output = '{message}' [/STATE] [STATE] output = '{message}\n' [/STATE] [STATE] output = '{message}\n{exception}' [/STATE]
        return output

strip([(1, ''), (1, '{message}'), (1, '\n'), (1, '{exception}')])

1: def strip(tokens):
2:         output = ""
3:         for type_, value in tokens:
4:             if type_ == TokenType.TEXT:
5:                 output += value
6:         return output
7:
8: strip([(1, ''), (1, '{message}'), (1, '\n'), (1, '{exception}')])

Question: What is the value of ' output ' in line '5' after '3' th iteration when 'strip([(1, ''), (1, '{message}'), (1, '\n'), (1, '{exception}')])' is executed?

Answer: '{message}\n{exception}'


def warn_about_celery_args_used_in_flower_command(ctx, flower_args):
    celery_options = [option for param in ctx.parent.command.params for option in param.opts] # [STATE] celery_options = ['-A', '--app', '-b', '--broker'] [/STATE]

    incorrectly_used_args = [] # [STATE] incorrectly_used_args = [] [/STATE]
    for arg in flower_args: #  [STATE] arg = '--port=5678' [/STATE] [STATE] arg = '--address=0.0.0.0' [/STATE]
        arg_name, _, _ = arg.partition("=") #  [STATE] arg_name = '--port' [/STATE] [STATE] _ = '5678' [/STATE] [STATE] arg_name = '--address' [/STATE] [STATE] _ = '0.0.0.0' [/STATE]
        if arg_name in celery_options:
            incorrectly_used_args.append(arg_name)

    if incorrectly_used_args:
        logger.warning(
            'You have incorrectly specified the following celery arguments after flower command:'
            ' %s. '
            'Please specify them after celery command instead following this template: '
            'celery [celery args] flower [flower args].', incorrectly_used_args
        )

warn_about_celery_args_used_in_flower_command({}, ('--port=5678', '--address=0.0.0.0'))

1: def warn_about_celery_args_used_in_flower_command(ctx, flower_args):
2:     celery_options = [option for param in ctx.parent.command.params for option in param.opts]
3:
4:     incorrectly_used_args = []
5:     for arg in flower_args:
6:         arg_name, _, _ = arg.partition("=")
7:         if arg_name in celery_options:
8:             incorrectly_used_args.append(arg_name)
9:
10:     if incorrectly_used_args:
11:         logger.warning(
12:             'You have incorrectly specified the following celery arguments after flower command:'
13:             ' %s. '
14:             'Please specify them after celery command instead following this template: '
15:             'celery [celery args] flower [flower args].', incorrectly_used_args
16:         )
17:
18: warn_about_celery_args_used_in_flower_command({}, ('--port=5678', '--address=0.0.0.0'))

Question: What is the value of ' _ ' in line '6' after '4' th iteration when 'warn_about_celery_args_used_in_flower_command({}, ('--port=5678', '--address=0.0.0.0'))' is executed?

Answer: '0.0.0.0'


def _position_of_committer_with_initials(all_committers: List[str], initials: str) -> int:
    for index, committer in enumerate(all_committers): #  [STATE] index = 0 [/STATE] [STATE] committer = 'initials1,name1,email1\n' [/STATE] [STATE] index = 1 [/STATE] [STATE] committer = 'initials2,name2,email2\n' [/STATE]
        if committer.startswith(initials):
            return index
    return _COMMITTER_NOT_PRESENT

_position_of_committer_with_initials(['initials1,name1,email1\n', 'initials2,name2,email2\n'], 'initials3')

1: def _position_of_committer_with_initials(all_committers: List[str], initials: str) -> int:
2:     for index, committer in enumerate(all_committers):
3:         if committer.startswith(initials):
4:             return index
5:     return _COMMITTER_NOT_PRESENT
6:
7: _position_of_committer_with_initials(['initials1,name1,email1\n', 'initials2,name2,email2\n'], 'initials3')

Question: What is the value of ' index ' in line '2' after '1' th iteration when '_position_of_committer_with_initials(['initials1,name1,email1\n', 'initials2,name2,email2\n'], 'initials3')' is executed?

Answer: 0


def which(exe=None):
    """
    Python clone of /usr/bin/which
    """

    if not exe:
        log.error("No executable was passed to be searched by salt.utils.path.which()")
        return None

    ## define some utilities (we use closures here because our predecessor used them)
    def is_executable_common(path): # [STATE] is_executable_common = <function which.<locals>.is_executable_common at 0x7f27d3207c10> [/STATE]
        """
        This returns truth if posixy semantics (which python simulates on
        windows) states that this is executable.
        """
        return os.path.isfile(path) and os.access(path, os.X_OK)

    def resolve(path): # [STATE] resolve = <function which.<locals>.resolve at 0x7f27d3207820> [/STATE]
        """
        This will take a path and recursively follow the link until we get to a
        real file.
        """
        while os.path.islink(path):
            res = readlink(path)

            # if the link points to a relative target, then convert it to an
            # absolute path relative to the original path
            if not os.path.isabs(res):
                directory, _ = os.path.split(path)
                res = join(directory, res)
            path = res
        return path

    # windows-only
    def has_executable_ext(path, ext_membership): # [STATE] has_executable_ext = <function which.<locals>.has_executable_ext at 0x7f27d31c20d0> [/STATE]
        """
        Extract the extension from the specified path, lowercase it so we
        can be insensitive, and then check it against the available exts.
        """
        p, ext = os.path.splitext(path)
        return ext.lower() in ext_membership

    ## prepare related variables from the environment
    res = salt.utils.stringutils.to_unicode(os.environ.get("PATH", "")) # [STATE] res = '/home/XXX/.gdrive-downloader:/local/arise/XXX/miniforge3/bin:/home/XXX/.gvm/pkgsets/go1.19.1/global/bin:/home/XXX/.gvm/gos/go1.19.1/bin:/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin:/home/XXX/.gvm/bin:/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin:/local/rcs/XXX/miniforge3/condabin:/home/XXX/.gdrive-downloader:/local/arise/XXX/miniforge3/bin:/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/XXX/.local/bin:/home/XXX/.local/bin' [/STATE]
    system_path = res.split(os.pathsep) # [STATE] system_path = ['/home/XXX/.gdrive-downloader', '/local/arise/XXX/miniforge3/bin', '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin', '/home/XXX/.gvm/gos/go1.19.1/bin', '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin', '/home/XXX/.gvm/bin', '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin', '/local/rcs/XXX/miniforge3/condabin', '/home/XXX/.gdrive-downloader', '/local/arise/XXX/miniforge3/bin', '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin', '/home/XXX/.local/bin', '/home/XXX/.local/bin'] [/STATE]

    # add some reasonable defaults in case someone's PATH is busted
    if not salt.utils.platform.is_windows():
        res = set(system_path) # [STATE] res = {'/usr/games', '/sbin', '/home/XXX/.gvm/gos/go1.19.1/bin', '/home/XXX/.gvm/bin', '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin', '/home/XXX/.local/bin', '/snap/bin', '/usr/bin', '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli', '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin', '/bin', '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin', '/usr/local/games', '/usr/local/sbin', '/home/XXX/.gdrive-downloader', '/local/rcs/XXX/miniforge3/condabin', '/local/arise/XXX/miniforge3/bin', '/usr/sbin', '/usr/local/bin'} [/STATE]
        extended_path = [ # [STATE] extended_path = ['/sbin', '/bin', '/usr/sbin', '/usr/bin', '/usr/local/sbin', '/usr/local/bin'] [/STATE]
            "/sbin",
            "/bin",
            "/usr/sbin",
            "/usr/bin",
            "/usr/local/sbin",
            "/usr/local/bin",
        ]
        system_path.extend([p for p in extended_path if p not in res])

    ## now to define the semantics of what's considered executable on a given platform
    if salt.utils.platform.is_windows():
        # executable semantics on windows requires us to search PATHEXT
        res = salt.utils.stringutils.to_str(os.environ.get("PATHEXT", ".EXE"))

        # generate two variables, one of them for O(n) searches (but ordered)
        # and another for O(1) searches. the previous guy was trying to use
        # memoization with a function that has no arguments, this provides
        # the exact same benefit
        pathext = res.split(os.pathsep)
        res = {ext.lower() for ext in pathext}

        # check if our caller already specified a valid extension as then we don't need to match it
        _, ext = os.path.splitext(exe)
        if ext.lower() in res:
            pathext = [""]

            is_executable = is_executable_common

        # The specified extension isn't valid, so we just assume it's part of the
        # filename and proceed to walk the pathext list
        else:
            is_executable = lambda path, membership=res: is_executable_common(
                path
            ) and has_executable_ext(path, membership)

    else:
        # in posix, there's no such thing as file extensions..only zuul
        pathext = [""] # [STATE] pathext = [''] [/STATE]

        # executable semantics are pretty simple on reasonable platforms...
        is_executable = is_executable_common # [STATE] is_executable = <function which.<locals>.is_executable_common at 0x7f27d3207c10> [/STATE]

    ## search for the executable

    # check to see if the full path was specified as then we don't need
    # to actually walk the system_path for any reason
    if is_executable(exe):
        return exe

    # now to search through our system_path
    for path in system_path: #  [STATE] path = '/home/XXX/.gdrive-downloader' [/STATE] [STATE] path = '/local/arise/XXX/miniforge3/bin' [/STATE] [STATE] path = '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin' [/STATE] [STATE] path = '/home/XXX/.gvm/gos/go1.19.1/bin' [/STATE] [STATE] path = '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin' [/STATE] [STATE] path = '/home/XXX/.gvm/bin' [/STATE] [STATE] path = '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin' [/STATE] [STATE] path = '/local/rcs/XXX/miniforge3/condabin' [/STATE] [STATE] path = '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli' [/STATE] [STATE] path = '/usr/local/sbin' [/STATE] [STATE] path = '/usr/local/bin' [/STATE] [STATE] path = '/usr/sbin' [/STATE] [STATE] path = '/usr/bin' [/STATE]
        p = join(path, exe) #  [STATE] p = '/home/XXX/.gdrive-downloader/true' [/STATE] [STATE] p = '/local/arise/XXX/miniforge3/bin/true' [/STATE] [STATE] p = '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin/true' [/STATE] [STATE] p = '/home/XXX/.gvm/gos/go1.19.1/bin/true' [/STATE] [STATE] p = '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin/true' [/STATE] [STATE] p = '/home/XXX/.gvm/bin/true' [/STATE] [STATE] p = '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin/true' [/STATE] [STATE] p = '/local/rcs/XXX/miniforge3/condabin/true' [/STATE] [STATE] p = '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli/true' [/STATE] [STATE] p = '/usr/local/sbin/true' [/STATE] [STATE] p = '/usr/local/bin/true' [/STATE] [STATE] p = '/usr/sbin/true' [/STATE] [STATE] p = '/usr/bin/true' [/STATE]

        # iterate through all extensions to see which one is executable
        for ext in pathext: #  [STATE] ext = '' [/STATE]
            pext = p + ext #  [STATE] pext = '/home/XXX/.gdrive-downloader/true' [/STATE] [STATE] pext = '/local/arise/XXX/miniforge3/bin/true' [/STATE] [STATE] pext = '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin/true' [/STATE] [STATE] pext = '/home/XXX/.gvm/gos/go1.19.1/bin/true' [/STATE] [STATE] pext = '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin/true' [/STATE] [STATE] pext = '/home/XXX/.gvm/bin/true' [/STATE] [STATE] pext = '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin/true' [/STATE] [STATE] pext = '/local/rcs/XXX/miniforge3/condabin/true' [/STATE] [STATE] pext = '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli/true' [/STATE] [STATE] pext = '/usr/local/sbin/true' [/STATE] [STATE] pext = '/usr/local/bin/true' [/STATE] [STATE] pext = '/usr/sbin/true' [/STATE] [STATE] pext = '/usr/bin/true' [/STATE]
            rp = resolve(pext) #  [STATE] rp = '/home/XXX/.gdrive-downloader/true' [/STATE] [STATE] rp = '/local/arise/XXX/miniforge3/bin/true' [/STATE] [STATE] rp = '/home/XXX/.gvm/pkgsets/go1.19.1/global/bin/true' [/STATE] [STATE] rp = '/home/XXX/.gvm/gos/go1.19.1/bin/true' [/STATE] [STATE] rp = '/home/XXX/.gvm/pkgsets/go1.19.1/global/overlay/bin/true' [/STATE] [STATE] rp = '/home/XXX/.gvm/bin/true' [/STATE] [STATE] rp = '/local/rcs/XXX/miniforge3/envs/saltstack+salt/bin/true' [/STATE] [STATE] rp = '/local/rcs/XXX/miniforge3/condabin/true' [/STATE] [STATE] rp = '/home/XXX/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/remote-cli/true' [/STATE] [STATE] rp = '/usr/local/sbin/true' [/STATE] [STATE] rp = '/usr/local/bin/true' [/STATE] [STATE] rp = '/usr/sbin/true' [/STATE] [STATE] rp = '/usr/bin/true' [/STATE]
            if is_executable(rp):
                return p + ext
            continue
        continue

    ## if something was executable, we should've found it already...
    log.trace(
        "'%s' could not be found in the following search path: '%s'", exe, system_path
    )
    return None

which('true')

1: def which(exe=None):
2:     """
3:     Python clone of /usr/bin/which
4:     """
5:
6:     if not exe:
7:         log.error("No executable was passed to be searched by salt.utils.path.which()")
8:         return None
9:
10:     ## define some utilities (we use closures here because our predecessor used them)
11:     def is_executable_common(path):
12:         """
13:         This returns truth if posixy semantics (which python simulates on
14:         windows) states that this is executable.
15:         """
16:         return os.path.isfile(path) and os.access(path, os.X_OK)
17:
18:     def resolve(path):
19:         """
20:         This will take a path and recursively follow the link until we get to a
21:         real file.
22:         """
23:         while os.path.islink(path):
24:             res = readlink(path)
25:
26:             # if the link points to a relative target, then convert it to an
27:             # absolute path relative to the original path
28:             if not os.path.isabs(res):
29:                 directory, _ = os.path.split(path)
30:                 res = join(directory, res)
31:             path = res
32:         return path
33:
34:     # windows-only
35:     def has_executable_ext(path, ext_membership):
36:         """
37:         Extract the extension from the specified path, lowercase it so we
38:         can be insensitive, and then check it against the available exts.
39:         """
40:         p, ext = os.path.splitext(path)
41:         return ext.lower() in ext_membership
42:
43:     ## prepare related variables from the environment
44:     res = salt.utils.stringutils.to_unicode(os.environ.get("PATH", ""))
45:     system_path = res.split(os.pathsep)
46:
47:     # add some reasonable defaults in case someone's PATH is busted
48:     if not salt.utils.platform.is_windows():
49:         res = set(system_path)
50:         extended_path = [
51:             "/sbin",
52:             "/bin",
53:             "/usr/sbin",
54:             "/usr/bin",
55:             "/usr/local/sbin",
56:             "/usr/local/bin",
57:         ]
58:         system_path.extend([p for p in extended_path if p not in res])
59:
60:     ## now to define the semantics of what's considered executable on a given platform
61:     if salt.utils.platform.is_windows():
62:         # executable semantics on windows requires us to search PATHEXT
63:         res = salt.utils.stringutils.to_str(os.environ.get("PATHEXT", ".EXE"))
64:
65:         # generate two variables, one of them for O(n) searches (but ordered)
66:         # and another for O(1) searches. the previous guy was trying to use
67:         # memoization with a function that has no arguments, this provides
68:         # the exact same benefit
69:         pathext = res.split(os.pathsep)
70:         res = {ext.lower() for ext in pathext}
71:
72:         # check if our caller already specified a valid extension as then we don't need to match it
73:         _, ext = os.path.splitext(exe)
74:         if ext.lower() in res:
75:             pathext = [""]
76:
77:             is_executable = is_executable_common
78:
79:         # The specified extension isn't valid, so we just assume it's part of the
80:         # filename and proceed to walk the pathext list
81:         else:
82:             is_executable = lambda path, membership=res: is_executable_common(
83:                 path
84:             ) and has_executable_ext(path, membership)
85:
86:     else:
87:         # in posix, there's no such thing as file extensions..only zuul
88:         pathext = [""]
89:
90:         # executable semantics are pretty simple on reasonable platforms...
91:         is_executable = is_executable_common
92:
93:     ## search for the executable
94:
95:     # check to see if the full path was specified as then we don't need
96:     # to actually walk the system_path for any reason
97:     if is_executable(exe):
98:         return exe
99:
100:     # now to search through our system_path
101:     for path in system_path:
102:         p = join(path, exe)
103:
104:         # iterate through all extensions to see which one is executable
105:         for ext in pathext:
106:             pext = p + ext
107:             rp = resolve(pext)
108:             if is_executable(rp):
109:                 return p + ext
110:             continue
111:         continue
112:
113:     ## if something was executable, we should've found it already...
114:     log.trace(
115:         "'%s' could not be found in the following search path: '%s'", exe, system_path
116:     )
117:     return None
118:
119: which('true')

Question: What is the value of ' p ' in line '102' after '10' th iteration when 'which('true')' is executed?

Answer: '/usr/local/sbin/true'