code: def remove_layer(nn, del_idx, additional_edges, new_strides=None):
      """Deletes the layer indicated in del_idx and adds additional_edges specified
      in additional_edges."""
      (
          layer_labels,
          num_units_in_each_layer,
          conn_mat,
          mandatory_child_attributes,
      ) = get_copies_from_old_nn(nn)
      # First add new edges to conn_mat and remove edges to and from del_idx
      for add_edge in additional_edges:
          conn_mat[add_edge[0], add_edge[1]] = 1
      conn_mat[del_idx, :] = 0
      conn_mat[:, del_idx] = 0
      # Now reorder everything so that del_idx is at the end
      all_idxs = list(range(len(layer_labels)))
      new_order = (
          all_idxs[:del_idx] + all_idxs[del_idx + 1 :] + [del_idx]
      )
      # Now reorder everything so that the layer to be remove is at the end
      layer_labels = reorder_list_or_array(layer_labels, new_order)
      num_units_in_each_layer = reorder_list_or_array(
          num_units_in_each_layer, new_order
      )
      conn_mat = reorder_rows_and_cols_in_matrix(conn_mat, new_order)
      # remove layer
      layer_labels = layer_labels[:-1]
      num_units_in_each_layer = num_units_in_each_layer[:-1]
      conn_mat = conn_mat[:-1, :-1]
      # Strides for a convolutional network
      if nn.nn_class == "cnn":
          new_strides = (
              new_strides
              if new_strides is not None
              else mandatory_child_attributes.strides
          )
          mandatory_child_attributes.strides = reorder_list_or_array(
              new_strides, new_order
          )
          mandatory_child_attributes.strides = (
              mandatory_child_attributes.strides[:-1]
          )
      return get_new_nn(
          nn,
          layer_labels,
          num_units_in_each_layer,
          conn_mat,
          mandatory_child_attributes,
      )
  
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 8 for calling a global function with example usage: remove_layer(nn, del_idx, additional_edges, new_strides) and returns: get_new_nn