code: def _create_nested_blocks(context, op_spec):
      """
      An utility function that creates nested blocks for control flow ops.
      """
      if not op_spec.blocks:
          return []
  
      blocks = []
  
      for block_spec in op_spec.blocks:
          input_vars = [
              _create_var_from_spec(input)
              for input in block_spec.inputs
          ]
  
          # add block input vars to the context
          for v in input_vars:
              context.register_var_with_name(v.name, v)
  
          # In pymil, the outer_op for a block can only be None if the block is a Function.
          # As the result, we use a dummy outer_op here for block creation, and set it to
          # the legit op later on in _set_outer_op_for_nested_blocks
          dummy = mb.const(val=0.0)
          with Block(
              block_inputs=input_vars,
              outer_op=dummy._op,
              name=Block._get_new_name(),
          ) as block:
              _load_block(context, block_spec)
  
          blocks.append(block)
  
      return blocks
  
imports: import os
  import numpy
  from coremltools import _logger
  from coremltools.converters.mil._deployment_compatibility import AvailableTarget
  from coremltools.converters.mil.backend.mil import helper
  from coremltools.converters.mil.mil import Block
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, ListVar, Placeholder, Program, TupleInputType, Var, mil_list, types
  from coremltools.converters.mil.mil.block import curr_block
  from coremltools.converters.mil.mil.ops.registry import SSAOpRegistry
  from coremltools.proto import MIL_pb2
  from coremltools.proto import Model_pb2
  from .helper import proto_to_types
label_desc: Use image node_id 7 for calling a global function with example usage: _create_nested_blocks(context, op_spec) and returns: blocks, list