code: def select_for_kth_multiselect(
      page: Page, option_text: str, k: int, close_after_selecting: bool
  ) -> None:
      """Select an option from a multiselect widget.
  
      Parameters
      ----------
      page : Page
          The playwright page to use.
      option_text : str
          The text of the option to select.
      k : int
          The index of the multiselect widget to select from.
      close_after_selecting : bool
          Whether to close the dropdown after selecting the option.
      """
  
      multiselect_elem = page.locator(".stMultiSelect").nth(k)
      multiselect_elem.locator("input").click()
      page.locator("li").filter(has_text=option_text).first.click()
      if close_after_selecting:
          page.keyboard.press("Escape")
      wait_for_app_run(page)
  
file_path: streamlit/e2e_playwright/st_multiselect_test.py
imports: from playwright.sync_api import Page, expect
  from e2e_playwright.conftest import ImageCompareFunction, wait_for_app_run
label_desc: Use image node_id 1 for calling a global function with example usage: select_for_kth_multiselect(page, option_text, k, close_after_selecting) without return types