How do I render a form? What is the alternative to drupal_get_form('user_login'). in Drupal 8?

I am using the following code in theme_name.theme, but it doesn't work.

// Include namespace for userLoginForm.
use \Drupal\Core\core\modules\user\src\Form;

function MYTHEMENAME_preprocess_page(&amp;$variables) {
  $form = UserLoginForm::create();
}
drupal_get_form() has been replaced by the form builder service, e.g.:

$form = \Drupal::formBuilder()-&gt;getForm(\Drupal\user\Form\UserLoginForm::class);


See the Change Record for more details.

Actually, don't - that change record is incorrect. It'll tell you to pass the form ID, when in fact you need to pass the class string.