main function.

def main():
    '''
    main function.
    '''

    args = parse_args()
    if args.multi_thread:
        enable_multi_thread()

    if args.advisor_class_name:
        # advisor is enabled and starts to run
        if args.multi_phase:
            raise AssertionError('multi_phase has not been supported in advisor')
        if args.advisor_class_name in AdvisorModuleName:
            dispatcher = create_builtin_class_instance(
                args.advisor_class_name,
                args.advisor_args, True)
        else:
            dispatcher = create_customized_class_instance(
                args.advisor_directory,
                args.advisor_class_filename,
                args.advisor_class_name,
                args.advisor_args)
        if dispatcher is None:
            raise AssertionError('Failed to create Advisor instance')
        try:
            dispatcher.run()
        except Exception as exception:
            logger.exception(exception)
            raise
    else:
        # tuner (and assessor) is enabled and starts to run
        tuner = None
        assessor = None
        if args.tuner_class_name in ModuleName:
            tuner = create_builtin_class_instance(
                args.tuner_class_name, 
                args.tuner_args)
        else:
            tuner = create_customized_class_instance(
                args.tuner_directory,
                args.tuner_class_filename,
                args.tuner_class_name,
                args.tuner_args)

        if tuner is None:
            raise AssertionError('Failed to create Tuner instance')

        if args.assessor_class_name:
            if args.assessor_class_name in ModuleName:
                assessor = create_builtin_class_instance(
                    args.assessor_class_name,
                    args.assessor_args)
            else:
                assessor = create_customized_class_instance(
                    args.assessor_directory,
                    args.assessor_class_filename,
                    args.assessor_class_name,
                    args.assessor_args)
            if assessor is None:
                raise AssertionError('Failed to create Assessor instance')

        if args.multi_phase:
            dispatcher = MultiPhaseMsgDispatcher(tuner, assessor)
        else:
            dispatcher = MsgDispatcher(tuner, assessor)

        try:
            dispatcher.run()
            tuner._on_exit()
            if assessor is not None:
                assessor._on_exit()
        except Exception as exception:
            logger.exception(exception)
            tuner._on_error()
            if assessor is not None:
                assessor._on_error()
            raise