docstr: Find the nearest Switch nodes upstream of node_name.
docstr_tok: ["Find","the","nearest","Switch","nodes","upstream","of","node_name","."]
code: def _search(g, node_name):
      """
      Find the nearest Switch nodes upstream of node_name.
      """
      node = g[node_name]
  
      switches = (
          FindAllUpstreamTerminals(lambda x: x.op == "Switch")
          .visit(g, node.name)
          .get_result()
      )
      if len(switches) == 0:
          switches = (
              FindAllUpstreamTerminals(
                  lambda x: x.op == "Switch"
                  or x.attr.get("was_switch") is not None
              )
              .visit(g, node.name)
              .get_result()
          )
      return switches
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/cond_to_where.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from ..basic_graph_ops import delete_node, disconnect_edge
  from .visitors import FindAllUpstreamTerminals
  import logging
  from coremltools._deps import _HAS_TF_2
label_desc: Use image node_id 1 for calling the CondToWhere obj's underlying member method code with example usage: obj._search(g, node_name) and returns: switches