code: def get_list_of_remove_layer_modifiers(old_nn):
      """Returns a list of primitives which remove a layer from a neural network."""
      # pylint: disable=too-many-locals
      # A local function to return the modifier
      if old_nn.num_processing_layers == 0:
          # Don't delete any layers if there are no processing layers.
          return []
  
      def _get_remove_modifier(_del_idx, _add_edges, *_args, **_kwargs):
          """Returns a modifier which deletes _del_idx and adds _add_edges."""
          return lambda arg_nn: remove_layer(
              arg_nn, _del_idx, _add_edges, *_args, **_kwargs
          )
  
      # Now check every layer
      ret = []
      for idx, ll in enumerate(old_nn.layer_labels):
          if ll in [
              "ip",
              "op",
              "softmax",
              "linear",
          ]:  # Don't delete any of these layers
              continue
          curr_parents = old_nn.get_parents(idx)
          parent_labels = [
              old_nn.layer_labels[par_idx] for par_idx in curr_parents
          ]
          if ll == "fc" and (
              not parent_labels == ["fc"] * len(parent_labels)
          ):
              # If the parents of a fc layer are also not fc then do not delete
              continue
          curr_children = old_nn.get_children(idx)
          if (
              old_nn.nn_class == "cnn"
              and old_nn.pre_img_inv_sizes[idx]
              != old_nn.post_img_inv_sizes[idx]
          ):
              change_stride_idxs = None
              # First check if the children are modifiable
              child_strides = [
                  old_nn.strides[ch_idx] for ch_idx in curr_children
              ]
              if child_strides == [1] * len(curr_children):
                  change_stride_idxs = curr_children  # we will change the strides of the children
              if change_stride_idxs is None:
                  parent_strides = [
                      old_nn.strides[par_idx]
                      for par_idx in curr_parents
                  ]
                  if parent_strides == [1] * len(curr_parents):
                      change_stride_idxs = curr_parents
              # If we have successfuly identified children/parents which we can modify, great!
              # Otherwise, lets not change anything and hope that it
              # does not break anything. If it does, there is an exception to handle this.
              if change_stride_idxs is not None:
                  new_strides = deepcopy(old_nn.strides)
                  for csi in change_stride_idxs:
                      new_strides[csi] = 2
              else:
                  new_strides = None
          else:
              new_strides = None
          # Now delete the layer and add new adges
          num_children_on_each_parent = [
              len(old_nn.get_children(par_idx))
              for par_idx in curr_parents
          ]
          num_parents_on_each_child = [
              len(old_nn.get_parents(ch_idx))
              for ch_idx in curr_children
          ]
          must_add_children = [
              curr_children[i]
              for i in range(len(curr_children))
              if num_parents_on_each_child[i] == 1
          ]
          must_add_parents = [
              curr_parents[i]
              for i in range(len(curr_parents))
              if num_children_on_each_parent[i] == 1
          ]
          num_must_add_children = len(must_add_children)
          num_must_add_parents = len(must_add_parents)
          np.random.shuffle(must_add_children)
          np.random.shuffle(must_add_parents)
          add_edges = []
          for _ in range(
              min(num_must_add_children, num_must_add_parents)
          ):
              add_edges.append(
                  (must_add_parents.pop(), must_add_children.pop())
              )
          # Add edges for left over children/parents
          if num_must_add_children > num_must_add_parents:
              diff = num_must_add_children - num_must_add_parents
              cand_parents = list(np.random.choice(curr_parents, diff))
              for _ in range(diff):
                  add_edges.append(
                      (cand_parents.pop(), must_add_children.pop())
                  )
          if num_must_add_parents > num_must_add_children:
              diff = num_must_add_parents - num_must_add_children
              cand_children = list(
                  np.random.choice(curr_children, diff)
              )
              for _ in range(diff):
                  add_edges.append(
                      (must_add_parents.pop(), cand_children.pop())
                  )
          ret.append(_get_remove_modifier(idx, add_edges, new_strides))
      return ret
  
imports: from argparse import Namespace
  from copy import deepcopy
  import numpy
  from .neural_network import ConvNeuralNetwork, MultiLayerPerceptron, MLP_RECTIFIERS, MLP_SIGMOIDS, is_a_pooling_layer_label, is_a_conv_layer_label, CNNImageSizeMismatchException, CNNNoConvAfterIPException
  from ..utils.general_utils import reorder_list_or_array, reorder_rows_and_cols_in_matrix
  from ..utils.option_handler import get_option_specs, load_options
  from ..utils.reporters import get_reporter
label_desc: Use image node_id 9 for calling a global function with example usage: get_list_of_remove_layer_modifiers(old_nn) and returns: ret, list, function