code: def _detect_pattern(program_op, ops_arrangement_root_var, block):
      # The goal of this function is to find the root variable of both operations
      program_op_inputs = program_op.get_flattened_inputs()
  
      for potential_program_root_variable in program_op_inputs:
          pattern = Pattern()
          pattern.set_block(block)
  
          if _pattern_detected(
              pattern,
              program_op,
              ops_arrangement_root_var.op,
              potential_program_root_variable,
              ops_arrangement_root_var,
              block,
          ):
              pattern.set_root_var(potential_program_root_variable)
  
              # check that none of the ops in this pattern is connected to the output
              # (except the last one)
              for op in pattern.op_list():
                  if op is not pattern.final_op:
                      for out in op.outputs:
                          if out in pattern.block.outputs:
                              return False, None
  
              return True, pattern
  
      return False, None
  
imports: import itertools
  import warnings
  from functools import partial
  from coremltools.converters.mil.mil.passes.helper import block_context_manager
  from ...mil.passes import pass_registry
label_desc: Use image node_id 3 for calling a global function with example usage: _detect_pattern(program_op, ops_arrangement_root_var, block) and returns: False,  None, True,  pattern, False,  None