<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run(create_application, settings=None, log_config=None):
 """ Run a Tornado create_application. :param create_application: function to call to create a new application instance :param dict|None settings: optional configuration dictionary that will be passed through to ``create_application`` as kwargs. :param dict|None log_config: optional logging configuration dictionary to use. By default, a reasonable logging configuration is generated based on settings. If you need to override the configuration, then use this parameter. It is passed as-is to :func:`logging.config.dictConfig`. .. rubric:: settings['debug'] If the `settings` parameter includes a value for the ``debug`` key, then the application will be run in Tornado debug mode. If the `settings` parameter does not include a ``debug`` key, then debug mode will be enabled based on the :envvar:`DEBUG` environment variable. .. rubric:: settings['port'] If the `settings` parameter includes a value for the ``port`` key, then the application will be configured to listen on the specified port. If this key is not present, then the :envvar:`PORT` environment variable determines which port to bind to. The default port is 8000 if nothing overrides it. .. rubric:: settings['number_of_procs'] If the `settings` parameter includes a value for the ``number_of_procs`` key, then the application will be configured to run this many processes unless in *debug* mode. This is passed to ``HTTPServer.start``. .. rubric:: settings['xheaders'] If the `settings` parameter includes a value for the ``xheaders`` key, then the application will be configured to use headers, like X-Real-IP, to get the user's IP address instead of attributing all traffic to the load balancer's IP address. When running behind a load balancer like nginx, it is recommended to pass xheaders=True. The default value is False if nothing overrides it. """

    from . import runner

    app_settings = {} if settings is None else settings.copy()
    debug_mode = bool(app_settings.get('debug',
                                       int(os.environ.get('DEBUG', 0)) != 0))
    app_settings['debug'] = debug_mode
    logging.config.dictConfig(_get_logging_config(debug_mode)
                              if log_config is None else log_config)

    port_number = int(app_settings.pop('port', os.environ.get('PORT', 8000)))
    num_procs = int(app_settings.pop('number_of_procs', '0'))
    server = runner.Runner(create_application(**app_settings))

    server.run(port_number, num_procs)