def run_main():
  """Initializes flags and calls main()."""
  program.setup_environment()

  if getattr(tf, '__version__', 'stub') == 'stub':
    print("TensorFlow installation not found - running with reduced feature set.",
          file=sys.stderr)

  tensorboard = program.TensorBoard(default.get_plugins(),
                                    program.get_default_assets_zip_provider())
  try:
    from absl import app
    # Import this to check that app.run() will accept the flags_parser argument.
    from absl.flags import argparse_flags
    app.run(tensorboard.main, flags_parser=tensorboard.configure)
    raise AssertionError("absl.app.run() shouldn't return")
  except ImportError:
    pass
  except base_plugin.FlagsError as e:
    print("Error: %s" % e, file=sys.stderr)
    sys.exit(1)

  tensorboard.configure(sys.argv)
  sys.exit(tensorboard.main())