Construct a Dash instance taking into account state

def form_dash_instance(self, replacements=None, ndid=None, base_pathname=None):
        'Construct a Dash instance taking into account state'

        if ndid is None:
            ndid = self._uid

        rd = WrappedDash(base_pathname=base_pathname,
                         expanded_callbacks=self._expanded_callbacks,
                         replacements=replacements,
                         ndid=ndid,
                         serve_locally=self._serve_locally)

        rd.layout = self.layout
        rd.config['suppress_callback_exceptions'] = self._suppress_callback_exceptions

        for cb, func in self._callback_sets:
            rd.callback(**cb)(func)
        for s in self.css.items:
            rd.css.append_css(s)
        for s in self.scripts.items:
            rd.scripts.append_script(s)

        return rd