code: def reduce_transposes_block(block):
      """
      Only apply the optimization if the block is flat,
      i.e, it does not contain any op which contains a sub-block.
      TODO:
      Removing transposes and transpose compliments requires re-running
      type inference for the set of ops in between the fused transpose ops,
      which is simpler to do when all the ops in the block are free of sub blocks.
      The case of transpose fusion with sub-block containing ops needs to be handled with more care and test cases.
      """
      for op in list(block.operations):
          if len(op.blocks) > 0:
              return
  
      opt_transposes = TransposeOptimization(block)
      opt_transposes.block_traversal()
      opt_transposes.apply_transform()
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil.var import Var
  import logging
  import numpy
  import copy
  from collections import defaultdict
label_desc: Use image node_id 4 for calling a global function with example usage: reduce_transposes_block(block) without return types