class_docstr: A CLI menu to select a choice from a list of choices using the keyboard.
class_docstr_tok: ["A","CLI","menu","to","select","a","choice","from","a","list","of","choices","using","the","keyboard","."]
docstr: Start the menu and return the selected choice
docstr_tok: ["Start","the","menu","and","return","the","selected","choice"]
code: def run(self, default_choice: int = 0):
      "Start the menu and return the selected choice"
      if self.prompt:
          linebreak()
          forceWrite(self.prompt, "\n")
          if in_colab:
              forceWrite(
                  "Please input a choice index (starting from 0), and press enter",
                  "\n",
              )
          else:
              forceWrite(
                  "Please select a choice using the arrow or number keys, and selecting with enter",
                  "\n",
              )
      self.position = default_choice
      for i in range(len(self.choices)):
          self.print_choice(i)
          forceWrite("\n")
      move_cursor(len(self.choices) - self.position, "UP")
      with cursor.hide():
          while True:
              if in_colab:
                  try:
                      choice = int(builtins.input())
                  except ValueError:
                      choice = default_choice
              else:
                  choice = self.handle_input()
              if choice is not None:
                  reset_cursor()
                  for _ in range(len(self.choices) + 1):
                      move_cursor(1, "UP")
                      clear_line()
                  self.write_choice(choice, "\n")
                  return choice
  
file_path: accelerate/src/accelerate/commands/menu/selection_menu.py
imports: import builtins
  import sys
  from ...utils.imports import _is_package_available
  from .None import cursor, input
  from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
  from .keymap import KEYMAP
label_desc: Use image node_id 10 for calling the BulletMenu obj's underlying member method code with example usage: obj.run(default_choice) and returns: choice