code: def get_new_nn(
      old_nn,
      layer_labels,
      num_units_in_each_layer,
      conn_mat,
      mandatory_child_attributes,
  ):
      """Returns a new neural network of the same type as old_nn."""
      known_nn_class = True
      try:
          if old_nn.nn_class == "cnn":
              new_cnn = ConvNeuralNetwork(
                  layer_labels,
                  conn_mat,
                  num_units_in_each_layer,
                  mandatory_child_attributes.strides,
                  old_nn.all_layer_label_classes,
                  old_nn.layer_label_similarities,
              )
              return new_cnn
          elif old_nn.nn_class.startswith("mlp"):
              return MultiLayerPerceptron(
                  old_nn.nn_class[4:],
                  layer_labels,
                  conn_mat,
                  num_units_in_each_layer,
                  old_nn.all_layer_label_classes,
                  old_nn.layer_label_similarities,
              )
          else:
              known_nn_class = False
      except (
          CNNImageSizeMismatchException,
          CNNNoConvAfterIPException,
          AssertionError,
      ):
          return None
      if not known_nn_class:
          raise ValueError(
              "Unidentified nn_class %s." % (old_nn.nn_class)
          )
  
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 2 for calling a global function with example usage: get_new_nn(old_nn, layer_labels, num_units_in_each_layer, conn_mat, mandatory_child_attributes) and returns: new_cnn, None, MultiLayerPerceptron