code: def _pattern_detected(
      pattern,
      program_op,
      pattern_op,
      program_root_var,
      pattern_root_var,
      block,
  ):
      # If the pattern_op is None, that means we are dealing with root_var checking (which don't have op_types or outputs)
      if (
          pattern_op is not None
          and program_op.op_type != pattern_op.op_type
      ):
          return False
  
      if pattern_op is not None and len(program_op.outputs) != len(
          pattern_op.outputs
      ):
          return False
  
      for i in range(
          len(program_op.outputs) if pattern_op is not None else 1
      ):
          output_same = False
  
          # ASSUMPTION: Assuming that the outputs of an operation are ordered in a particular way
          # So, two identical operations will have the same ordering of outputs.
          program_child_op_list = (
              list(program_op.outputs[i].child_ops)
              if pattern_op is not None
              else program_root_var.child_ops
          )
          pattern_child_op_list = (
              list(pattern_op.outputs[i].child_ops)
              if pattern_op is not None
              else pattern_root_var.child_ops
          )
  
          # Last op in the pattern
          if len(pattern_child_op_list) == 0:
              if (
                  pattern.final_op is not None
                  and pattern.final_op != program_op
              ):
                  warnings.warn(
                      "User defined pattern matched to more than one final operation. "
                      "Skipped the pattern matching."
                  )
                  return False
              pattern.set_final_op(pattern_op.name, program_op)
              return True
  
          if len(program_child_op_list) != len(pattern_child_op_list):
              return False
  
          # Permuting the program child operations so that at least one of the permutations will be in
          # the exact same order as the pattern child operations
          op_combos = list(
              itertools.permutations(pattern_child_op_list)
          )
  
          for combo in op_combos:
              if _lists_op_equality(combo, program_child_op_list):
                  truly_equal = True
  
                  for i in range(len(combo)):
                      truly_equal = truly_equal and _pattern_detected(
                          pattern,
                          program_child_op_list[i],
                          combo[i],
                          program_root_var,
                          pattern_root_var,
                          block,
                      )
  
                  if truly_equal:
                      # The operations in this sequence match perfectly with the pattern
                      output_same = True
                      break
  
          if output_same is False:
              return False
  
      if pattern_op is not None:
          pattern.add_op(pattern_op.name, program_op)
      return True
  
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 2 for calling a global function with example usage: _pattern_detected(pattern, program_op, pattern_op, program_root_var, pattern_root_var, block) and returns: True, False, False, True, False, False, False