docs: public void pretrainLayer(int layerIdx, INDArray features) {
          setInput(features);
          setLayerMaskArrays(null, null);
  
          if (flattenedGradients == null) {
              initGradientsView();
          }
          if (layerIdx >= layers.length) {
              throw new IllegalArgumentException(
                      "Cannot pretrain layer: layerIdx (" + layerIdx + ") >= numLayers (" + layers.length + ")");
          }
  
          LayerWorkspaceMgr workspaceMgr;
          if(layerWiseConfigurations.getTrainingWorkspaceMode() == WorkspaceMode.NONE){
              workspaceMgr = LayerWorkspaceMgr.noWorkspaces();
          } else {
              workspaceMgr = LayerWorkspaceMgr.builder()
                      .defaultWorkspace(WS_LAYER_WORKING_MEM, WS_LAYER_WORKING_MEM_CONFIG)
                      .with(ArrayType.RNN_FF_LOOP_WORKING_MEM, WS_RNN_LOOP_WORKING_MEM, WS_RNN_LOOP_WORKING_MEM_CONFIG)
                      .build();
          }
          workspaceMgr.setHelperWorkspacePointers(helperWorkspaces);
  
          Layer layer = layers[layerIdx];
          if (!layer.isPretrainLayer())
              return;
  
          //Do forward pass to the layer to be pretrained
          INDArray outputOfPrevLayer;
          if(layerIdx == 0) {
              outputOfPrevLayer = input;
          } else {
              //Yes, this part of training - but we'll do forward psas as inference mode when doing layerwise training
              // to effectively freeze earlier layers and not apply dropout etc
              outputOfPrevLayer = outputOfLayerDetached(false, FwdPassType.STANDARD, layerIndex-1, features, null, null, null);
          }
  
          try(MemoryWorkspace ws = workspaceMgr.notifyScopeEntered(ArrayType.FF_WORKING_MEM)) {
              if (layerWiseConfigurations.getInputPreProcess(layerIdx) != null) {
  
                  // FIXME: int cast
                  outputOfPrevLayer = layerWiseConfigurations.getInputPreProcess(layerIdx).preProcess(outputOfPrevLayer, (int) input.size(0),
                          LayerWorkspaceMgr.noWorkspaces(helperWorkspaces));
              }
  
              layer.fit(outputOfPrevLayer, workspaceMgr);
          }
      }