class_docstr: Class for generating conditional trees based on value of an expression.
  
  Examples
  --------
  
  >>> csq = hl.literal('loss of function')
  >>> expr = (hl.switch(csq)
  ...           .when('synonymous', 1)
  ...           .when('SYN', 1)
  ...           .when('missense', 2)
  ...           .when('MIS', 2)
  ...           .when('loss of function', 3)
  ...           .when('LOF', 3)
  ...           .or_missing())
  >>> hl.eval(expr)
  3
  
  Notes
  -----
  All expressions appearing as the `then` parameters to
  :meth:`~hail.expr.builders.SwitchBuilder.when` or
  :meth:`~hail.expr.builders.SwitchBuilder.default` method calls must be the
  same type.
  
  See Also
  --------
  :func:`.case`, :func:`.cond`, :func:`.switch`
  
  Parameters
  ----------
  expr : :class:`.Expression`
      Value to match against.
class_docstr_tok: ["Class","for","generating","conditional","trees","based","on","value","of","an","expression",".","Examples","--","--","--","--",">",">",">","csq","=","hl.literal","(","'loss","of","function","'",")",">",">",">","expr","=","(","hl.switch","(","csq",")","...",".when","(","'synonymous","'",",","1",")","...",".when","(","'SYN","'",",","1",")","...",".when","(","'missense","'",",","2",")","...",".when","(","'MIS","'",",","2",")","...",".when","(","'loss","of","function","'",",","3",")","...",".when","(","'LOF","'",",","3",")","...",".or_missing","(",")",")",">",">",">","hl.eval","(","expr",")","3","Notes","--","--","-","All","expressions","appearing","as","the","`","then","`","parameters","to",":","meth",":","`","~hail.expr.builders.SwitchBuilder.when","`","or",":","meth",":","`","~hail.expr.builders.SwitchBuilder.default","`","method","calls","must","be","the","same","type",".","See","Also","--","--","--","--",":","func",":","`",".case","`",",",":","func",":","`",".cond","`",",",":","func",":","`",".switch","`","Parameters","--","--","--","--","--","expr",":",":","class",":","`",".Expression","`","Value","to","match","against","."]
code: def _finish(self, default):
      assert len(self._cases) > 0 or self._when_missing_case is not None
  
      def f(base):
          # build cond chain bottom-up
          if default is self._base:
              expr = base
          else:
              expr = default
          for value, then in self._cases[::-1]:
              expr = hl.if_else(base == value, then, expr)
          # needs to be on the outside, because upstream missingness would propagate
          if self._when_missing_case is not None:
              expr = hl.if_else(
                  hl.is_missing(base), self._when_missing_case, expr
              )
          return expr
  
      return hl.bind(f, self._base)
  
imports: import hail
  from hail.typecheck import typecheck_method
  from hail.expr.expressions import unify_types, unify_types_limited, expr_any, expr_bool, ExpressionException, construct_expr, expr_str
  from hail import ir
label_desc: Use image node_id 2 for calling the SwitchBuilder obj's underlying member method code with example usage: obj._finish(default) and returns: hl, expr