class_docstr: Graph Optimizer that merges different cond ops
code: def apply(self, fgraph):
      nodelist = list(fgraph.toposort())
      cond_nodes = [s for s in nodelist if isinstance(s.op, IfElse)]
      if len(cond_nodes) < 2:
          return False
      merging_node = cond_nodes[0]
      for proposal in cond_nodes[1:]:
          if proposal.inputs[0] == merging_node.inputs[
              0
          ] and not apply_depends_on(proposal, merging_node):
              # Create a list of replacements for proposal
              mn_ts = merging_node.inputs[1:][: merging_node.op.n_outs]
              mn_fs = merging_node.inputs[1:][merging_node.op.n_outs :]
              pl_ts = proposal.inputs[1:][: proposal.op.n_outs]
              pl_fs = proposal.inputs[1:][proposal.op.n_outs :]
              new_ins = (
                  [merging_node.inputs[0]]
                  + mn_ts
                  + pl_ts
                  + mn_fs
                  + pl_fs
              )
              mn_name = "?"
              if merging_node.op.name:
                  mn_name = merging_node.op.name
              pl_name = "?"
              # mn_n_ts = len(mn_ts)
              # mn_n_fs = len(mn_fs)
              if proposal.op.name:
                  pl_name = proposal.op.name
              new_ifelse = IfElse(
                  n_outs=len(mn_ts + pl_ts),
                  as_view=False,
                  name=mn_name + "&" + pl_name,
              )
              new_outs = new_ifelse(*new_ins, return_list=True)
              new_outs = [clone_replace(x) for x in new_outs]
              old_outs = []
              if not isinstance(merging_node.outputs, (list, tuple)):
                  old_outs += [merging_node.outputs]
              else:
                  old_outs += merging_node.outputs
              if not isinstance(proposal.outputs, (list, tuple)):
                  old_outs += [proposal.outputs]
              else:
                  old_outs += proposal.outputs
              pairs = list(zip(old_outs, new_outs))
              fgraph.replace_all_validate(pairs, reason="cond_merge")
  
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 2 for calling the CondMerge obj's underlying member method code with example usage: obj.apply(fgraph) and returns: False