def calculate_nearest_labels(images_ids, annotations, figures_ids, top_n=5, padding=0):
    data_for_nn = generate_data_for_nn_app(images_ids=images_ids, annotations=annotations, figures_ids=figures_ids, padding=padding)
    response = g.api.task.send_request(g.nn_session_id, 'inference', data={'input_data': data_for_nn}, timeout=99999)
    embeddings_by_indexes = ast.literal_eval(json.loads(response))
    if (len(embeddings_by_indexes) != len(data_for_nn)):
        raise ValueError(f'Data error. Check that the label is selected correctly.')
    add_embeddings_to_cache_by_figures(embeddings_by_indexes, data_for_nn)
    data_for_calculator = generate_data_for_calculator_app(embeddings_by_indexes, top_n)
    response = g.api.task.send_request(g.calculator_session_id, 'calculate_similarity', data={'input_data': data_for_calculator}, timeout=99999)
    nearest_labels = ast.literal_eval(json.loads(response))
    return nearest_labels
def calculate_nearest_labels(images_ids, annotations, figures_ids, top_n=5, padding=0):
    data_for_nn = generate_data_for_nn_app(images_ids=images_ids, annotations=annotations, figures_ids=figures_ids, padding=padding)
    response = g.api.task.send_request(g.nn_session_id, 'inference', data={'input_data': data_for_nn}, timeout=99999)
    embeddings_by_indexes = ast.literal_eval(json.loads(response))
    if (len(embeddings_by_indexes) != len(data_for_nn)):
        raise ValueError(f'Data error. Check that the label is selected correctly.')
    add_embeddings_to_cache_by_figures(embeddings_by_indexes, data_for_nn)
    data_for_calculator = generate_data_for_calculator_app(embeddings_by_indexes, top_n)
    response = g.api.task.send_request(g.calculator_session_id, 'calculate_similarity', data={'input_data': data_for_calculator}, timeout=99999)
    nearest_labels = ast.literal_eval(json.loads(response))
    return nearest_labels