code: public static INDArrayIndex interval(long begin, long stride, long end,long max) {
          if(begin < 0) {
              begin += max;
          }
  
          if(end < 0) {
              end += max;
          }
  
          if (Math.abs(begin - end) < 1)
              end++;
          if (stride > 1 && Math.abs(begin - end) == 1) {
              end *= stride;
          }
          return interval(begin, stride, end, false);
      }
docs: Generates an interval from begin (inclusive) to end (exclusive)
  
  @param begin the begin
  @param stride  the stride at which to increment
  @param end   the end index
  @param max the max length for this domain
  @return the interval