code: def ifelse(
      condition: "TensorLike",
      then_branch: Union[Any, Sequence[Any]],
      else_branch: Union[Any, Sequence[Any]],
      name: Optional[str] = None,
  ) -> Union[Variable, Sequence[Variable]]:
      """Construct a graph for an ``if`` statement.
  
      Parameters
      ----------
      condition
          `condition` should be a tensor scalar representing the condition.
          If it evaluates to ``0`` it corresponds to ``False``, anything else
          stands for ``True``.
  
      then_branch
          A single variable or a list of variables that the
          function should return as the output if `condition` evaluates to
          true. The number of variables should match those in the
          `else_branch`, as well as the dtypes and numbers of dimensions of each
          tensor.
  
      else_branch
          A single variable or a list of variables that the function should
          return as the output if `condition` evaluates to false. The number of
          variables should match those in `then_branch`, as well as the dtypes
          and numbers of dimensions of each tensor.
  
      Returns
      -------
          A sequence of variables or a single variable, depending on the
          nature of `then_branch` and `else_branch`.  More exactly, if
          `then_branch` and `else_branch` is are single variables, then
          the return variable will also be a single variable; otherwise, it will
          be a sequence. The value returned correspond to either the values in
          the `then_branch` or in the `else_branch` depending on the value of
          `condition`.
      """
  
      rval_type = None
      if isinstance(then_branch, (list, tuple)):
          rval_type = type(then_branch)
      else:
          then_branch = [then_branch]
  
      if not isinstance(else_branch, (list, tuple)):
          else_branch = [else_branch]
  
      if len(then_branch) != len(else_branch):
          raise ValueError(
              "The number of values on the `then` branch "
              "must match the `else` branch: got "
              f"{len(then_branch)} for `then`, and "
              f"{len(else_branch)} for `else`."
          )
  
      new_ifelse = IfElse(
          n_outs=len(then_branch), as_view=False, name=name
      )
  
      ins = [condition] + list(then_branch) + list(else_branch)
      rval = new_ifelse(*ins, return_list=True)
  
      if rval_type is None:
          return rval[0]
      elif rval_type is list:
          return list(rval)
      else:
          return tuple(rval)
  
imports: from collections.abc import Sequence
  from copy import deepcopy
  from typing import TYPE_CHECKING, Any, Optional, Union
  import numpy
  import pytensor.tensor
  from pytensor import as_symbolic
  from pytensor.compile import optdb
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Apply, Variable, apply_depends_on
  from pytensor.graph.op import _NoPythonOp
  from pytensor.graph.replace import clone_replace
  from pytensor.graph.rewriting.basic import GraphRewriter, in2out, node_rewriter
  from pytensor.graph.type import HasDataType, HasShape
  from pytensor.tensor.shape import Reshape, Shape, SpecifyShape, Unbroadcast
label_desc: Use image node_id 1 for calling a global function with example usage: ifelse(condition, then_branch, else_branch, name) and returns: rval, list, tuple