code: def bool_cast(string: str) -> Union[bool, str]:
      """Cast a string to a boolean if possible, otherwise return the string."""
      if string.lower() == "true" or string == "1":
          return True
      elif string.lower() == "false" or string == "0":
          return False
      else:
          return string
  
file_path: ray/dashboard/modules/job/cli_utils.py
imports: from typing import Union
  import click
  import functools
label_desc: Use image node_id 1 for calling a global function with example usage: bool_cast(string) and returns: True, False, string