code: def remove_vacuous_cond(prog):
      """
      Remove cond op and it's sub-graphs that produces identity on both then and
      else branch. One example use case is the TensorListReverse op, in Core ML,
      we dynamically resize in write operations, and thus, both branches of the
      cond op will be a skip (identity) op.
  
      Given:
  
          main(%a: (1, bool),
           %b: (2, 3, fp32)) {
            block0() {
              %squeeze_0: (bool) = squeeze(x=%a, name="squeeze_0")
              %cond_0: (2, 3, fp32) = cond(pred=%squeeze_0, name="cond_0")
                cond_0_true() {
                  %identity_0: (2, 3, fp32) = identity(x=%b, name="identity_0")
                } -> (%identity_0)
                cond_0_false() {
                  %identity_1: (2, 3, fp32) = identity(x=%b, name="identity_1")
                } -> (%identity_1)
            } -> (%cond_0)
          }
  
      Result:
  
          main(%a: (1, bool),
               %b: (2, 3, fp32)) {
            block0() {
              %squeeze_0: (bool) = squeeze(x=%a, name="squeeze_0")
              %cond_0: (2, 3, fp32) = identity(x=%b, name="cond_0")
            } -> (%cond_0)
          }
      """
      for f_name, f in prog.functions.items():
          num_changes = remove_vacuous_cond_block(f)
          msg = "remove_vacuous_cond: changed {} ops in function '{}'"
          logging.info(msg.format(num_changes, f_name))
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: remove_vacuous_cond(prog) without return types