docs: @Override
      public void applyUpdate(StepFunction function, INDArray params, INDArray updates, double alpha) {
          try {
              // nullify given updates first
              Nd4j.getMemoryManager().memset(updates);
              //updates.assign(0.0);
  
              int cnt = 0;
              while (!messages.get(index.get()).isEmpty()) {
                  INDArray compressed = messages.get(index.get()).poll();
  
                  int encoding = compressed.data().getInt(3);
                  if (encoding == ThresholdCompression.FLEXIBLE_ENCODING)
                      Nd4j.getExecutioner().thresholdDecode(compressed, updates);
                  else if (encoding == ThresholdCompression.BITMAP_ENCODING)
                      Nd4j.getExecutioner().bitmapDecode(compressed, updates);
                  else
                      throw new DL4JInvalidConfigException("Unknown compression header received: " + encoding);
  
                  cnt++;
              }
  
              if (cnt > 0 && isDebug)
                  log.info("Local updates to be applied: {}", cnt);
  
              if (externalSource != null) {
                  int ent = 0;
                  if (externalSource.hasAnything()) {
                      externalSource.drainTo(updates);
  
                      cnt++;
                      ent++;
                  }
  
                  if (ent > 0 && isDebug)
                      log.info("External updates to be applied: {}", ent);
              }
  
              synchronize(currentConsumers.get(), true);
  
              // TODO: average updates? might have sense
  
              if (cnt > 0)
                  function.step(params, updates, alpha);
          } catch (Exception e) {
              throwable.setIfFirst(e);
              throw new RuntimeException(e);
          }
      }