def _update_shape(api, task_id, label_id, label=None, points=None, attributes=None, occluded=None):
    anno_json = api.get(api.task_annotation_url(task_id)).json()
    shape = _find_shape(anno_json, label_id)
    if (shape is not None):
        if (points is not None):
            shape['points'] = points
        if (occluded is not None):
            shape['occluded'] = occluded
        if (attributes is not None):
            (attr_id_map, class_id_map) = api._get_attr_class_maps(task_id)
            if (label is None):
                label_id = shape['label_id']
                attr_id_map = attr_id_map[label_id]
            else:
                label_id = class_id_map[label]
                prev_attr_id_map = attr_id_map[shape['label_id']]
                prev_attr_id_map = {v: k for (k, v) in prev_attr_id_map.items()}
                attr_id_map = attr_id_map[label_id]
                shape['label_id'] = label_id
                for attr in shape['attributes']:
                    spec = prev_attr_id_map[attr['spec_id']]
                    attr['spec_id'] = attr_id_map[spec]
            for (attr_name, attr_val) in attributes:
                if (attr_name in attr_id_map):
                    shape['attributes'].append({'spec_id': attr_id_map[attr_name], 'value': attr_val})
        update_json = {'version': 1, 'tags': [], 'shapes': [shape], 'tracks': []}
        update_url = (api.task_annotation_url(task_id) + '?action=update')
        api.patch(update_url, json=update_json)
def _update_shape(api, task_id, label_id, label=None, points=None, attributes=None, occluded=None):
    anno_json = api.get(api.task_annotation_url(task_id)).json()
    shape = _find_shape(anno_json, label_id)
    if (shape is not None):
        if (points is not None):
            shape['points'] = points
        if (occluded is not None):
            shape['occluded'] = occluded
        if (attributes is not None):
            (attr_id_map, class_id_map) = api._get_attr_class_maps(task_id)
            if (label is None):
                label_id = shape['label_id']
                attr_id_map = attr_id_map[label_id]
            else:
                label_id = class_id_map[label]
                prev_attr_id_map = attr_id_map[shape['label_id']]
                prev_attr_id_map = {v: k for (k, v) in prev_attr_id_map.items()}
                attr_id_map = attr_id_map[label_id]
                shape['label_id'] = label_id
                for attr in shape['attributes']:
                    spec = prev_attr_id_map[attr['spec_id']]
                    attr['spec_id'] = attr_id_map[spec]
            for (attr_name, attr_val) in attributes:
                if (attr_name in attr_id_map):
                    shape['attributes'].append({'spec_id': attr_id_map[attr_name], 'value': attr_val})
        update_json = {'version': 1, 'tags': [], 'shapes': [shape], 'tracks': []}
        update_url = (api.task_annotation_url(task_id) + '?action=update')
        api.patch(update_url, json=update_json)