code: def test_grbs004_graph_loading_state_updates(dash_dcc):
      lock = Lock()
      app = Dash(__name__, suppress_callback_exceptions=True)
      app.layout = html.Div(
          [
              html.H1(id="title", children="loading state updates"),
              dcc.Graph(id="my-graph"),
          ]
      )
  
      @app.callback(
          Output("my-graph", "figure"), [Input("title", "n_clicks")]
      )
      def update_graph(n_clicks):
          values = [0, n_clicks]
          ranges = [0, n_clicks]
  
          with lock:
              return {
                  "data": [
                      {
                          "x": ranges,
                          "y": values,
                          "line": {"shape": "spline"},
                      }
                  ],
              }
  
      dash_dcc.start_server(app)
      dash_dcc.wait_for_element("#my-graph:not([data-dash-is-loading])")
  
      with lock:
          title = dash_dcc.wait_for_element("#title")
          title.click()
          dash_dcc.wait_for_element(
              '#my-graph[data-dash-is-loading="true"]'
          )
  
      dash_dcc.wait_for_element("#my-graph:not([data-dash-is-loading])")
  
      assert dash_dcc.get_logs() == []
  
file_path: dash/components/dash-core-components/tests/integration/graph/test_graph_basics.py
imports: import json
  import pytest
  import pandas
  from multiprocessing import Value, Lock
  import numpy
  from time import sleep
  import plotly.express
  import plotly.graph_objects
  from dash import Dash, Input, Output, dcc, html
  import dash.testing.wait
label_desc: Use image node_id 4 for calling a global function with example usage: test_grbs004_graph_loading_state_updates(dash_dcc) and returns: dict