def update_card_buttons(card_name, assigned_tags, fields, state):
    current_card = fields.get(f'state.{card_name}', None)
    if (current_card is None):
        current_card = g.api.task.get_field(g.task_id, f'state.{card_name}')
    if current_card:
        assign_disabled = True
        reference_disabled = True
        if ((current_card.get('current_label', '') not in assigned_tags) and (not ((len(assigned_tags) > 0) and state['tagPerImage']))):
            assign_disabled = False
        selected_figure_id = fields.get('state.selectedFigureId', (- 1))
        if (selected_figure_id not in g.figures_in_reference):
            reference_disabled = False
        set_buttons(assign_disabled=assign_disabled, reference_disabled=reference_disabled, card_name=card_name, fields=fields)
def update_card_buttons(card_name, assigned_tags, fields, state):
    current_card = fields.get(f'state.{card_name}', None)
    if (current_card is None):
        current_card = g.api.task.get_field(g.task_id, f'state.{card_name}')
    if current_card:
        assign_disabled = True
        reference_disabled = True
        if ((current_card.get('current_label', ) not in assigned_tags) and (not ((len(assigned_tags) > 0) and state['tagPerImage']))):
            assign_disabled = False
        selected_figure_id = fields.get('state.selectedFigureId', (- 1))
        if (selected_figure_id not in g.figures_in_reference):
            reference_disabled = False
        set_buttons(assign_disabled=assign_disabled, reference_disabled=reference_disabled, card_name=card_name, fields=fields)