nl_tokens: Adjust final scheme to presence of bounds
pl_tokens: public static INDArray [ ] adjustSchemeToBounds ( INDArray x , INDArray h , int numSteps , INDArray lowerBound , INDArray upperBound ) { INDArray oneSided = Nd4j . onesLike ( h ) ; if ( and ( lowerBound . eq ( Double . NEGATIVE_INFINITY ) , upperBound . eq ( Double . POSITIVE_INFINITY ) ) . sumNumber ( ) . doubleValue ( ) > 0 ) { return new INDArray [ ] { h , oneSided } ; } INDArray hTotal = h . mul ( numSteps ) ; INDArray hAdjusted = h . dup ( ) ; INDArray lowerDist = x . sub ( lowerBound ) ; INDArray upperBound2 = upperBound . sub ( x ) ; INDArray central = and ( greaterThanOrEqual ( lowerDist , hTotal ) , greaterThanOrEqual ( upperBound2 , hTotal ) ) ; INDArray forward = and ( greaterThanOrEqual ( upperBound , lowerDist ) , not ( central ) ) ; hAdjusted . put ( forward , <mask> ( h . get ( forward ) , upperBound2 . get ( forward ) . mul ( 0.5 ) . divi ( numSteps ) ) ) ; oneSided . put ( forward , Nd4j . scalar ( 1.0 ) ) ; INDArray backward = and ( upperBound2 . lt ( lowerBound ) , not ( central ) ) ; hAdjusted . put ( backward , min ( h . get ( backward ) , lowerDist . get ( backward ) . mul ( 0.5 ) . divi ( numSteps ) ) ) ; oneSided . put ( backward , Nd4j . scalar ( 1.0 ) ) ; INDArray minDist = min ( upperBound2 , lowerDist ) . divi ( numSteps ) ; INDArray adjustedCentral = and ( not ( central ) , lessThanOrEqual ( abs ( hAdjusted ) , minDist ) ) ; hAdjusted . put ( adjustedCentral , minDist . get ( adjustedCentral ) ) ; oneSided . put ( adjustedCentral , Nd4j . scalar ( 0.0 ) ) ; return new INDArray [ ] { hAdjusted , oneSided } ; }