code: def deepen(self, idx, new_layer_config, input_dim):
      assert idx < len(self.layers), "Index out of range: %d" % idx
      if new_layer_config["name"] == "fc":
          assert idx == len(self.layers) - 1 or isinstance(
              self.layers[idx + 1], FCLayer
          ), "Invalid"
          assert isinstance(self.layers[idx], FCLayer) or isinstance(
              self.layers[idx], PoolLayer
          ), "Invalid"
          # prepare the new fc layer
          units = input_dim
          for _i in range(idx, -1, -1):
              if isinstance(self.layers[_i], FCLayer):
                  units = self.layers[_i].units
                  break
              elif isinstance(self.layers[_i], ConvLayer):
                  units = self.layers[_i].filter_num
                  break
          fc_idx = 0
          for _i in range(0, idx + 1):
              if isinstance(self.layers[_i], FCLayer):
                  fc_idx += 1
          _id = "fc_%d" % fc_idx
          # change the id of following fc layers
          for _i in range(idx + 1, len(self.layers)):
              if isinstance(self.layers[_i], FCLayer):
                  self.layers[_i].id = "fc_%d" % (fc_idx + 1)
                  fc_idx += 1
          prev_layer = None
          for _i in range(idx, -1, -1):
              if self.layers[_i].ready:
                  prev_layer = self.layers[_i]
                  break
          assert prev_layer is not None, "Invalid"
          new_fc_layer = FCLayer(
              _id, units, ready=False, **new_layer_config
          )
          # insert the new layer into the cascade
          self.layers = (
              self.layers[: idx + 1]
              + [new_fc_layer]
              + self.layers[idx + 1 :]
          )
          return new_fc_layer, prev_layer
      elif new_layer_config["name"] == "conv":
          assert idx == len(self.layers) - 1 or not isinstance(
              self.layers[idx + 1], FCLayer
          ), "Invalid"
          assert isinstance(self.layers[idx], ConvLayer) or isinstance(
              self.layers[idx], FCLayer
          ), "Invalid"
          # prepare the new conv layer
          filter_num = input_dim
          for _i in range(idx, -1, -1):
              if isinstance(self.layers[_i], ConvLayer):
                  filter_num = self.layers[_i].filter_num
                  break
          conv_idx = 0
          for _i in range(0, idx + 1):
              if isinstance(self.layers[_i], ConvLayer):
                  conv_idx += 1
          _id = "conv_%d" % conv_idx
          # change the id of following conv layers
          for _i in range(idx + 1, len(self.layers)):
              if isinstance(self.layers[_i], ConvLayer):
                  self.layers[_i].id = "conv_%d" % (conv_idx + 1)
                  conv_idx += 1
          prev_layer = None
          for _i in range(idx, -1, -1):
              if self.layers[_i].ready:
                  prev_layer = self.layers[_i]
                  break
          assert prev_layer is not None, "Invalid"
          new_conv_layer = ConvLayer(
              _id, filter_num, ready=False, **new_layer_config
          )
          self.layers = (
              self.layers[: idx + 1]
              + [new_conv_layer]
              + self.layers[idx + 1 :]
          )
          return new_conv_layer, prev_layer
      else:
          raise ValueError(
              "Not support to insert a %s layer"
              % new_layer_config["name"]
          )
  
file_path: auptimizer/Examples/cai_eas/eas/models/layer_cascade.py
imports: from models.layers import ConvLayer, FCLayer, PoolLayer, get_layer_by_name
  import tensorflow
label_desc: Use image node_id 14 for calling the LayerCascade obj's underlying member method code with example usage: obj.deepen(idx, new_layer_config, input_dim) and returns: new_fc_layer,  prev_layer, new_conv_layer,  prev_layer