code: def get_list_of_swap_layer_modifiers(
      nn,
      num_modifications="all",
      change_stride_with_prob=0.05,
      rectifier_swap_candidates=None,
      sigmoid_swap_candidates=None,
  ):
      """Returns a list of modifiers for swapping a layer with another."""
  
      # pylint: disable=too-many-statements
      # Define a local function to return the modifier
      def _get_swap_layer_modifier(
          _layer_idx, _replace_with, _new_stride
      ):
          """Returns a modifier for swapping a layer."""
          return lambda arg_nn: swap_layer_type(
              arg_nn, _layer_idx, _replace_with, _new_stride
          )
  
      # Preprocessing
      if nn.nn_class.startswith("mlp"):
          rectifier_swap_candidates = (
              rectifier_swap_candidates
              if rectifier_swap_candidates is not None
              else _DFLT_RECTIFIER_SWAP
          )
          sigmoid_swap_candidates = (
              sigmoid_swap_candidates
              if sigmoid_swap_candidates is not None
              else _DFLT_SIGMOID_SWAP
          )
      # Determine the order of the layers
      layer_order = list(range(nn.num_layers))
      if (
          num_modifications == "all"
          or num_modifications >= nn.num_layers
      ):
          num_modifications = nn.num_layers
      else:
          np.random.shuffle(layer_order)
      # iterate through the layers and return
      ret = []
      for idx in layer_order:
          ll = nn.layer_labels[idx]
          if ll in ["ip", "op", "fc", "softmax", "linear"]:
              continue  # don't swap out any of these
          # Determine candidates for swapping out
          if ll == "conv3":
              candidates = [
                  "res3",
                  "res5",
                  "conv5",
                  "conv7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.15, 0.25, 0.05, 0.05]
          elif ll == "conv5":
              candidates = [
                  "res3",
                  "res5",
                  "conv3",
                  "conv7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.2, 0.2, 0.05, 0.05]
          elif ll == "conv7":
              candidates = [
                  "res3",
                  "res5",
                  "conv3",
                  "conv5",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.25, 0.15, 0.05, 0.05]
          elif ll == "conv9":
              candidates = [
                  "res3",
                  "res5",
                  "conv3",
                  "conv5",
                  "conv7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.2, 0.2, 0.2, 0.2, 0.1, 0.05, 0.05]
          elif ll == "res3":
              candidates = [
                  "conv3",
                  "conv5",
                  "res5",
                  "res7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.15, 0.25, 0.05, 0.05]
          elif ll == "res5":
              candidates = [
                  "conv3",
                  "conv5",
                  "res3",
                  "res7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.2, 0.2, 0.05, 0.05]
          elif ll == "res7":
              candidates = [
                  "conv3",
                  "conv5",
                  "res3",
                  "res5",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.25, 0.25, 0.25, 0.15, 0.05, 0.05]
          elif ll == "res9":
              candidates = [
                  "conv3",
                  "conv5",
                  "res3",
                  "res5",
                  "res7",
                  "max-pool",
                  "avg-pool",
              ]
              cand_probs = [0.2, 0.2, 0.2, 0.2, 0.1, 0.05, 0.05]
          elif ll == "avg-pool":
              candidates = ["max-pool"]
              cand_probs = None
          elif ll == "max-pool":
              candidates = ["avg-pool"]
              cand_probs = None
          elif ll in MLP_RECTIFIERS:
              candidates = sigmoid_swap_candidates
              cand_probs = None
          elif ll in MLP_SIGMOIDS:
              candidates = rectifier_swap_candidates
              cand_probs = None
          else:
              raise ValueError("Unidentified layer_type: %s." % (ll))
          # I am determining the probabilities above completely ad-hoc for reasons I don't
          # know why.
          # Choose replace_with
          if cand_probs is not None:
              cand_probs = np.array(cand_probs)
              cand_probs = cand_probs / cand_probs.sum()
          replace_with = np.random.choice(candidates, 1, p=cand_probs)[
              0
          ]
          # Determine the stride
          if nn.nn_class == "cnn":
              if is_a_pooling_layer_label(replace_with):
                  new_stride = None
              elif is_a_conv_layer_label(
                  replace_with
              ) and is_a_pooling_layer_label(ll):
                  new_stride = 2
              elif (
                  is_a_conv_layer_label(ll)
                  and np.random.random() < change_stride_with_prob
              ):
                  new_stride = 1 if nn.strides[idx] == 2 else 2
              else:
                  new_stride = nn.strides[idx]
          else:
              new_stride = None
          # Create modifier and append
          ret.append(
              _get_swap_layer_modifier(idx, replace_with, new_stride)
          )
          if len(ret) >= num_modifications:
              break  # Check if you have exceeded the maximum amount
      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 18 for calling a global function with example usage: get_list_of_swap_layer_modifiers(nn, num_modifications, change_stride_with_prob, rectifier_swap_candidates, sigmoid_swap_candidates) and returns: ret, function