Duplicate Callback Output Error | UnboundLocalError - HELP

I have two equal callbacks. The only difference between them is the function. I’ve set allow_duplicate= True on both of them inside the Output. And I also have set Dash(__ name __, prevent_initial_callbacks=“initial_duplicate”). However the following error is still happening:

Duplicate Callback Outputs
In the callback for output(s):
  graph.figure@a8b70adf69db29fef22e63e51b22165f
Output 0 (graph.figure@a8b70adf69db29fef22e63e51b22165f) is already in use.
To resolve this, set `allow_duplicate=True` on
duplicate outputs, or combine the outputs into
one callback function, distinguishing the trigger
by using `dash.callback_context` if necessary.

What is going on? Helppp

Hello, you have to set it to True, not to initial_duplicate

Hi! I did it. As I said, allow_duplicate=True was passed. I set this parameter into the second callback. And I also set Dash(__ name __, prevent_initial_callbacks=“initial_duplicate”) as the documentation says. As a matter of fact I actually reached my goal, however when I created another callback (this one is pretty much the same although there is another Output) and the problem started again. Is it possible to have the same Output in 3 different callbacks? This is the error I’m getting:

⛑️
Duplicate callback outputs
12:11:32
In the callback for output(s):
  graph.figure@a8b70adf69db29fef22e63e51b22165f
  graph_2.figure
Output 0 (graph.figure@a8b70adf69db29fef22e63e51b22165f) is already in use.
To resolve this, set `allow_duplicate=True` on
duplicate outputs, or combine the outputs into
one callback function, distinguishing the trigger
by using `dash.callback_context` if necessary.

My code:

sidebar = html.Div(
    [
        html.H2("MPT", className="display-4", style= {'text-align':'center', 'color':'red'}),
        html.H3('Dashboard', style= {'text-align':'center', 'color':'brown'}),
        html.Hr(),
        html.P("Selecione abaixo as informações de interesse:", className="lead"),
        html.P('Composição', style= {'font-weight':'bold', 'text-decoration': 'underline'}),
        dcc.RadioItems(options=[
            {'label':'Força de Trabalho Total', 'value':'FT'},
            {'label':'Membras/Membros', 'value':'MM'},
            {'label':'Servidores', 'value':'S'}], value= 'FT', id= 'comp'),
        html.Hr(),
        html.P('Gratificação', style= {'font-weight':'bold', 'text-decoration': 'underline'}),
        dcc.RadioItems(options=[
            {'label':'Indiferente', 'value':'Ind'},
            {'label':'Com Função', 'value':'CF'},
            {'label':'Sem Função', 'value':'SF'}], value= 'Ind', id= 'grat'),
        html.Hr(),
        html.P('Informação', style= {'font-weight':'bold', 'text-decoration': 'underline'}),
        dcc.Checklist(options=[
            {'label':'Gênero', 'value':'gen'},
            {'label':'Cor/Raça', 'value':'C/R'},
            {'label':'Faixa de Idade', 'value':'FxI'},
            {'label':'Pessoa com Deficiência', 'value':'PCD'}], value= ['gen'], id= 'info'),
        html.Br(),
        dbc.Button('Gerar', id= 'button', n_clicks= 0)
    ],
    style= SIDEBAR_STYLE
)

app.layout = dbc.Container([sidebar, 
                            html.Div([dcc.Graph(id= 'graph', figure= {}),
                                     html.Br(),
                                     dcc.Graph(id= 'graph_2', figure= {})], style= RIGHT_INFO_STYLE)
                            ])

@app.callback(
    Output('graph', 'figure'),
    Input('button', 'n_clicks'),
    State('comp', 'value'),
    State('grat', 'value'),
    State('info', 'value') 
)
def FT_func(n_clicks, comp_value, grat_value, info_value):
        if grat_value == 'Ind' and info_value == ['gen'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'CF' and info_value == ['gen'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'SF' and info_value == ['gen'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'Ind' and info_value == ['C/R'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'CF' and info_value == ['C/R'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'SF' and info_value == ['C/R'] and comp_value == 'FT':
                  [...]
        elif grat_value == 'Ind' and info_value == ['FxI'] and comp_value == 'FT':
                  [...]
         elif grat_value == 'CF' and info_value == ['FxI'] and comp_value == 'FT':
                  [...]
         elif grat_value == 'SF' and info_value == ['FxI'] and comp_value == 'FT':
                  [...]
        else:
                pass
      
       return fig

I still have another callback very similar to this one.
And the last callback has two outputs and follows the same logic, except that each conditional has two figures being made and the function itself returns fig and fig_2.

I removed for a moment the third callback. However, I’m now getting a different error. This one:

UnboundLocalError: cannot access local variable 'fig' where it is not associated with a value

And the plots actually normally appear if I’m not wrong. What I’m noticing different is the fact that when I resize the browser’s window, the plot is not automatically fitting. I don’t know if you know what I mean…

Each time I trigger the callback, the figure correctly appears, but this error pops up at the same time.

EDIT : I managed to rewrite the first function in a way I could embed the second function (which was pretty much the same). Image bellow. Now, all the callbacks are working fine, BUT I’m still receiving this error each time I trigger a callback.