code: def dead_code_elimination_block(block):
      used_vars = set()
      ops_to_remove = list()
  
      # mark block's outputs to used
      used_vars.update(block.outputs)
  
      for op in reversed(block.operations):
          # if none of op's output is used, delete op
          if not set(op.outputs).intersection(used_vars):
              ops_to_remove.append(op)
              continue
  
          # mark all op's inputs to used
          for _, input_var in op.inputs.items():
              if isinstance(input_var, (tuple, list)):
                  used_vars.update(list(input_var))
              else:
                  used_vars.update([input_var])
  
          for b in op.blocks:
              used_in_block = dead_code_elimination_block(b)
              used_vars.update(used_in_block)
  
      for op in ops_to_remove:
          logging.info(
              'Removing op "{}" (type: {})'.format(op.name, op.op_type)
          )
          op.remove_from_block()
  
      return used_vars
  
imports: from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  import logging
label_desc: Use image node_id 1 for calling a global function with example usage: dead_code_elimination_block(block) and returns: used_vars