def parse(self, args):
        if len(args) == 1 and args[0] in ['-h', '--help']:
            self._parser.print_help()
            return None

        # Parse train pipeline options
        pipeline_options, extra_args = self._parser.parse_known_args(args)
        config_option, _ = self._config_option_parser.parse_known_args(args)

        options = Namespace()
        options.pipeline = pipeline_options
        options.model = None
        options.model_api = None

        # Parse specific model options if there are model parsers
        if self._models is not None:
            if pipeline_options.model not in self._models:
                raise KeyError('Invalid model: {}'.format(
                    pipeline_options.model))

            if config_option:
                extra_args = ['--config', config_option.config] + extra_args

            # Check if there are model parsers
            model_parser = self._models[pipeline_options.model]
            model_options, remaining_args = model_parser.parse_known_args(
                extra_args)

            options.model = model_options
            # Retrieve the respective API for the selected model
            options.model_api = model_parser.api_module
        else:
            remaining_args = extra_args

        options.all_options = merge_namespaces(options.pipeline, options.model)

        if remaining_args:
            raise KeyError('Unrecognized options: {}'.format(remaining_args))

        return options
    def parse(self, args):
        if len(args) == 1 and args[0] in ['-h', '--help']:
            self._parser.print_help()
            return None

        # Parse train pipeline options
        meta_options, extra_args = self._parser.parse_known_args(args)
        print(meta_options)

        if hasattr(meta_options, self._pipeline_config_key):
            extra_args = [
                '--config',
                getattr(meta_options, self._pipeline_config_key),
            ] + extra_args

        pipeline_options = self._pipeline_parser.parse(extra_args)

        options = Namespace()
        options.meta = meta_options
        options.pipeline = pipeline_options

        return options