def generate_output(self, args=None):
        """
        Generate text output by querying the Ludwig model with the dialogue
        acts in the arguments.

        :param args: a dictionary of arguments that contain the dialogue acts
        :return: the output utterance
        """
        if not args:
            print('WARNING! camrest_nlg called without arguments!')
            return ''

        if 'args' in args:
            dacts = args['args']

        elif 'dacts' not in args:
            print('WARNING! camrest_nlg called without dacts!')
            return ''

        else:
            dacts = args['dacts']

        system = True
        if 'system' in args:
            system = bool(args['system'])

        last_sys_utterance = None
        if 'last_sys_utterance' in args:
            last_sys_utterance = args['last_sys_utterance']

        dacts_str = ''
        dacts_str_tmp = ''
        slot2value = {}

        # Convert dacts to templates
        for dact in dacts:
            dacts_str_tmp += ' ' + str(dact)
            dacts_str += 'act_' + dact.intent + ' '

            for param in dact.params:

                if param.value:
                    dacts_str += '<' + param.slot + '> '
                    slot2value['<' + param.slot + '>'] = param.value
                elif param.slot:
                    dacts_str += 'slot_' + param.slot + ' '

        dacts_str = re.sub("\s+", " ", dacts_str.strip())

        # 'act_inform <name>' is not in the dstc2
        if dacts_str == 'act_inform <name>':
            dacts_str = 'act_offer <name>'

        if not system and last_sys_utterance and \
                'welcome' not in last_sys_utterance:
            dacts_str = last_sys_utterance + ' ' + dacts_str

        # Apply nlg model
        result = \
            super(CamRestNLG, self).generate_output(
                {'dacts': dacts_str, 'system': system})

        sys_text = ' '.join([x for x in result['nlg_output_predictions'][0]])
        sys_text = sys_text.replace(' <PAD>', '')

        # Replace template slots with values
        for key, value in slot2value.items():
            # Add some variability to 'dontcare'
            if value == 'dontcare':
                value = random.choice(['dont care', 'any', 'i dont care',
                                       'i do not care'])

            sys_text = sys_text.replace(key, value)

        sys_text = sys_text.strip()

        return sys_text

        Generate text output by querying the Ludwig model with the dialogue
        acts in the arguments.

        :param args: a dictionary of arguments that contain the dialogue acts
        :return: the output utterance
        
applications/cambridge_restaurants/camrest_nlg.py