Repository: deepjavalibrary/djl
Pull request #3149 (2024-05-02 19:08:28)

[ci] Updates google code formatter to 1.22.0
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/api/src/main/java/ai/djl/nn/convolutional/Convolution.java b/api/src/main/java/ai/djl/nn/convolutional/Convolution.java
index a049c20e2..edb1df359 100644
--- a/api/src/main/java/ai/djl/nn/convolutional/Convolution.java
+++ b/api/src/main/java/ai/djl/nn/convolutional/Convolution.java
@@ -285,6 +285,7 @@ public abstract class Convolution extends AbstractBlock {
         return input.getNDArrayInternal()
                 .convolution(input, weight, bias, stride, padding, dilation, groups);
     }
+
     /**
      * A builder that can build any {@code Convolution} block.
      *
diff --git a/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java b/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java
index 419780a98..dc14af707 100644
--- a/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java
+++ b/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java
@@ -197,6 +197,7 @@ public abstract class Deconvolution extends AbstractBlock {
         return input.getNDArrayInternal()
                 .deconvolution(input, weight, bias, stride, padding, outPadding, dilation, groups);
     }
+
     /**
      * A builder that can build any {@code Deconvolution} block.
      *
@@ -246,6 +247,7 @@ public abstract class Deconvolution extends AbstractBlock {
             this.padding = padding;
             return self();
         }
+
         /**
          * Sets the out_padding along each dimension. Defaults to 0 along each dimension.
          *
@@ -256,6 +258,7 @@ public abstract class Deconvolution extends AbstractBlock {
             this.outPadding = outPadding;
             return self();
         }
+
         /**
          * Sets the dilation along each dimension. Defaults to 1 along each dimension.
          *
diff --git a/api/src/main/java/ai/djl/nn/transformer/BertBlock.java b/api/src/main/java/ai/djl/nn/transformer/BertBlock.java
index af2c5c175..627a74fd2 100644
--- a/api/src/main/java/ai/djl/nn/transformer/BertBlock.java
+++ b/api/src/main/java/ai/djl/nn/transformer/BertBlock.java
@@ -283,6 +283,7 @@ public final class BertBlock extends AbstractBlock {
         float hiddenDropoutProbability = 0.1f;
         // float attentionDropoutProbability = 0.1f;
         int maxSequenceLength = 512;
+
         // float initializerRange = 0.02f;
 
         private Builder() {}
diff --git a/api/src/main/java/ai/djl/nn/transformer/ScaledDotProductAttentionBlock.java b/api/src/main/java/ai/djl/nn/transformer/ScaledDotProductAttentionBlock.java
index fa293f4b3..a6ecbb0ec 100644
--- a/api/src/main/java/ai/djl/nn/transformer/ScaledDotProductAttentionBlock.java
+++ b/api/src/main/java/ai/djl/nn/transformer/ScaledDotProductAttentionBlock.java
@@ -72,16 +72,22 @@ public final class ScaledDotProductAttentionBlock extends AbstractBlock {
 
     /** Size of the Word-/Token-embeddings we use the attention on. */
     private int embeddingSize;
+
     /** Number of attention heads. */
     private int headCount;
+
     /** Pointwise Linear projection of the keys. */
     private Linear keyProjection;
+
     /** Pointwise Linear projection of the queries. */
     private Linear queryProjection;
+
     /** Pointwise Linear projection of the values. */
     private Linear valueProjection;
+
     /** Pointwise Linear projection of the results. */
     private Linear resultProjection;
+
     /** Dropout operation to be applied after probability calculation. */
     private Dropout attentionProbsDropout;
 
@@ -119,6 +125,7 @@ public final class ScaledDotProductAttentionBlock extends AbstractBlock {
     public Linear getKeyProjection() {
         return keyProjection;
     }
+
     /**
      * Pointwise Linear projection of the queries.
      *
@@ -127,6 +134,7 @@ public final class ScaledDotProductAttentionBlock extends AbstractBlock {
     public Linear getQueryProjection() {
         return queryProjection;
     }
+
     /**
      * Pointwise Linear projection of the values.
      *
@@ -135,6 +143,7 @@ public final class ScaledDotProductAttentionBlock extends AbstractBlock {
     public Linear getValueProjection() {
         return valueProjection;
     }
+
     /**
      * Pointwise Linear projection of the results.
      *
diff --git a/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java b/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java
index f01cb1adc..8d2d8d69b 100644
--- a/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java
+++ b/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java
@@ -31,14 +31,19 @@ public class TransformerEncoderBlock extends AbstractBlock {
 
     /** The attention mechanism. */
     private ScaledDotProductAttentionBlock selfAttentionBlock;
+
     /** Dropout before residual & layer normalization. */
     private Dropout selfAttentionDropout;
+
     /** Normalization of attention output and residual. */
     private BatchNorm attentionNorm;
+
     /** Fully connected pointwise block for output projection. */
     private PointwiseFeedForwardBlock pointWisefullyConnected;
+
     /** Dropout after fully connected and before last residual & layer normalization. */
     private Dropout fullyConnectedDropout;
+
     /** Another normalization for the output and residual. */
     private BatchNorm outputNorm;
 
diff --git a/api/src/main/java/ai/djl/repository/SimpleUrlRepository.java b/api/src/main/java/ai/djl/repository/SimpleUrlRepository.java
index b01ed33c3..171d8b6b3 100644
--- a/api/src/main/java/ai/djl/repository/SimpleUrlRepository.java
+++ b/api/src/main/java/ai/djl/repository/SimpleUrlRepository.java
@@ -90,7 +90,7 @@ public class SimpleUrlRepository extends AbstractRepository {
                 return Collections.singletonList(mrl);
             }
         } catch (IOException e) {
-            logger.warn("Failed to connect URL: " + uri, e);
+            logger.warn("Failed to connect URL: {}", uri, e);
         }
         return Collections.emptyList();
     }
@@ -141,7 +141,7 @@ public class SimpleUrlRepository extends AbstractRepository {
                 conn.setRequestMethod("HEAD");
                 int code = conn.getResponseCode();
                 if (code != 200) {
-                    logger.info("request error: " + code);
+                    logger.info("request error: {}", code);
                     return -1;
                 }
                 return conn.getContentLength();
diff --git a/api/src/main/java/ai/djl/repository/zoo/ModelZoo.java b/api/src/main/java/ai/djl/repository/zoo/ModelZoo.java
index 4d8b77108..fa8e48934 100644
--- a/api/src/main/java/ai/djl/repository/zoo/ModelZoo.java
+++ b/api/src/main/java/ai/djl/repository/zoo/ModelZoo.java
@@ -302,7 +302,7 @@ public abstract class ModelZoo {
                 Utils.deleteQuietly(tmp);
             }
         } catch (IOException e) {
-            logger.warn("Failed load index of models: " + app, e);
+            logger.warn("Failed load index of models: {}", app, e);
         }
 
         return Collections.emptyMap();
diff --git a/api/src/main/java/ai/djl/training/ParameterServer.java b/api/src/main/java/ai/djl/training/ParameterServer.java
index 54261931e..0dda061aa 100644
--- a/api/src/main/java/ai/djl/training/ParameterServer.java
+++ b/api/src/main/java/ai/djl/training/ParameterServer.java
@@ -39,6 +39,7 @@ public interface ParameterServer extends AutoCloseable {
         update(parameterId, grads, params);
         Arrays.stream(grads).forEach(NDArray::close);
     }
+
     /**
      * Updates the parameter of a key from Parameter Server.
      *
diff --git a/api/src/main/java/ai/djl/training/listener/EpochTrainingListener.java b/api/src/main/java/ai/djl/training/listener/EpochTrainingListener.java
index e92110e96..c2a8c7fdc 100644
--- a/api/src/main/java/ai/djl/training/listener/EpochTrainingListener.java
+++ b/api/src/main/java/ai/djl/training/listener/EpochTrainingListener.java
@@ -35,6 +35,7 @@ public class EpochTrainingListener extends TrainingListenerAdapter {
         epochTime = System.nanoTime();
         numEpochs++;
     }
+
     /** {@inheritDoc} */
     @Override
     public void onTrainingBegin(Trainer trainer) {
diff --git a/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java b/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java
index b906c3980..86d7b721f 100644
--- a/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java
+++ b/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java
@@ -177,7 +177,7 @@ public class MemoryTrainingListener extends TrainingListenerAdapter {
                     metrics.addMetric("rss", rss, Unit.BYTES);
                 }
             } catch (IOException e) {
-                logger.error("Failed execute cmd: " + cmd, e);
+                logger.error("Failed execute cmd: {}", cmd, e);
             }
         }
     }
diff --git a/api/src/main/java/ai/djl/util/NativeResource.java b/api/src/main/java/ai/djl/util/NativeResource.java
index 9d83d49a4..3cc91919f 100644
--- a/api/src/main/java/ai/djl/util/NativeResource.java
+++ b/api/src/main/java/ai/djl/util/NativeResource.java
@@ -58,7 +58,7 @@ public abstract class NativeResource<T> implements AutoCloseable {
         T reference = handle.get();
         if (reference == null) {
             if (TRACK_RESOURCE) {
-                logger.error("Native resource " + uid + " is released. Closed at:", exception);
+                logger.error("Native resource {} is released. Closed at:", uid, exception);
             }
             String message = "Native resource has been released already.";
             throw new IllegalStateException(message);
diff --git a/api/src/main/java/ai/djl/util/Platform.java b/api/src/main/java/ai/djl/util/Platform.java
index b2ce08c38..2ab25c2f3 100644
--- a/api/src/main/java/ai/djl/util/Platform.java
+++ b/api/src/main/java/ai/djl/util/Platform.java
@@ -305,7 +305,7 @@ public final class Platform {
                         <= Integer.parseInt(system.flavor.substring(2, 5))) {
             return true;
         }
-        logger.warn("The bundled library: " + this + " doesn't match system: " + system);
+        logger.warn("The bundled library: {}} doesn't match system: {}", this, system);
         return false;
     }
 
diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java
index b1ca8e49a..7f96ee0d6 100644
--- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java
+++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java
@@ -124,11 +124,9 @@ public class CachedOp extends NativeResource<Pointer> {
                 String key = pair.getKey();
                 if (!"prob_label".equals(key) && !"softmax_label".equals(key)) {
                     logger.warn(
-                            "Input "
-                                    + key
-                                    + " not found, set NDArray to Shape("
-                                    + batchSize
-                                    + ") by default");
+                            "Input {} not found, set NDArray to Shape({}) by default",
+                            key,
+                            batchSize);
                 }
                 allInputsNDArray[pair.getValue()] =
                         (MxNDArray) inputManager.create(new Shape(batchSize));
diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxOpParams.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxOpParams.java
index cea8fd2e6..61e48266c 100644
--- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxOpParams.java
+++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxOpParams.java
@@ -23,6 +23,7 @@ public class MxOpParams extends PairList<String, Object> {
 
     // mxnet cpu take index
     private static final String MXNET_CPU = "cpu(0)";
+
     /**
      * Sets the Shape parameter.
      *
diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/jna/JnaUtils.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/jna/JnaUtils.java
index d5930cdba..3ec9aab02 100644
--- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/jna/JnaUtils.java
+++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/jna/JnaUtils.java
@@ -908,6 +908,7 @@ public final class JnaUtils {
         REFS.recycle(ref);
         return pointer;
     }
+
     /*
     int MXNDArraySetGradState(Pointer handle, int state);
 
diff --git a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtEngine.java b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtEngine.java
index 7f48547b4..f909a5788 100644
--- a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtEngine.java
+++ b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtEngine.java
@@ -69,8 +69,8 @@ public final class PtEngine extends Engine {
                             + " inference latency and throughput. See:"
                             + " https://docs.djl.ai/docs/development/inference_performance_optimization.html#graph-executor-optimization");
             }
-            logger.info("Number of inter-op threads is " + JniUtils.getNumInteropThreads());
-            logger.info("Number of intra-op threads is " + JniUtils.getNumThreads());
+            logger.info("Number of inter-op threads is {}", JniUtils.getNumInteropThreads());
+            logger.info("Number of intra-op threads is {}", JniUtils.getNumThreads());
 
             String paths = Utils.getEnvOrSystemProperty("PYTORCH_EXTRA_LIBRARY_PATH");
             if (paths != null) {
diff --git a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArrayEx.java b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArrayEx.java
index b7f92cbd1..e9eb8b2b7 100644
--- a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArrayEx.java
+++ b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArrayEx.java
@@ -437,6 +437,7 @@ public class PtNDArrayEx implements NDArrayEx {
                         manager.from(beta),
                         eps));
     }
+
     /** {@inheritDoc} */
     @Override
     public NDList batchNorm(
diff --git a/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfNDArrayEx.java b/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfNDArrayEx.java
index b7c9ec3e0..5160a6b1c 100644
--- a/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfNDArrayEx.java
+++ b/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfNDArrayEx.java
@@ -398,6 +398,7 @@ public class TfNDArrayEx implements NDArrayEx {
             NDArray input, Shape normalizedShape, NDArray gamma, NDArray beta, float eps) {
         throw new UnsupportedOperationException();
     }
+
     /** {@inheritDoc} */
     @Override
     public NDList batchNorm(
diff --git a/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfSymbolBlock.java b/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfSymbolBlock.java
index 2453e58c2..25b803df6 100644
--- a/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfSymbolBlock.java
+++ b/engines/tensorflow/tensorflow-engine/src/main/java/ai/djl/tensorflow/engine/TfSymbolBlock.java
@@ -75,17 +75,14 @@ public class TfSymbolBlock extends AbstractSymbolBlock implements AutoCloseable
         } else {
             Set<String> keys = signatureDefMap.keySet();
             logger.warn(
-                    "SignatureDefKey: "
-                            + signatureDefKey
-                            + "not found in Saved Model Bundle."
-                            + "Available keys: "
-                            + String.join(" ", keys)
-                            + "Please use .optOption(\"SignatureDefKey\", \"value\") with"
-                            + " Criteria.builder to load the model.Normally the value is"
-                            + " \"default\" for TF1.x models and \"serving_default\" for TF2.x"
-                            + " models. Refer to:"
-                            + " https://www.tensorflow.org/guide/saved_modelLoading the model using"
-                            + " next available key.");
+                    "SignatureDefKey: {} not found in Saved Model Bundle.Available keys: {} Please"
+                        + " use .optOption(\"SignatureDefKey\", \"value\") with Criteria.builder to"
+                        + " load the model.Normally the value is \"default\" for TF1.x models and"
+                        + " \"serving_default\" for TF2.x models. Refer to:"
+                        + " https://www.tensorflow.org/guide/saved_modelLoading the model using"
+                        + " next available key.",
+                    signatureDefKey,
+                    String.join(" ", keys));
             servingDefault = signatureDefMap.get(keys.iterator().next());
         }
         describeInput();
diff --git a/examples/src/main/java/ai/djl/examples/inference/BertClassification.java b/examples/src/main/java/ai/djl/examples/inference/BertClassification.java
index 954704517..dcea78b25 100644
--- a/examples/src/main/java/ai/djl/examples/inference/BertClassification.java
+++ b/examples/src/main/java/ai/djl/examples/inference/BertClassification.java
@@ -60,12 +60,14 @@ public final class BertClassification {
 
         Classifications[] results = predict(inputs);
         for (int i = 0; i < inputs.size(); i++) {
-            logger.info("Prediction for: " + inputs.get(i) + "\n" + results[i].toString());
+            logger.info("Prediction for: {}\n{}", inputs.get(i), results[i]);
         }
     }
 
     public static Classifications[] predict(List<String> inputs)
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
         // refer to
         // https://medium.com/delvify/bert-rest-inference-from-the-fine-tuned-model-499997b32851 and
diff --git a/examples/src/main/java/ai/djl/examples/inference/SentimentAnalysis.java b/examples/src/main/java/ai/djl/examples/inference/SentimentAnalysis.java
index e83e27fcc..c2ee112d5 100644
--- a/examples/src/main/java/ai/djl/examples/inference/SentimentAnalysis.java
+++ b/examples/src/main/java/ai/djl/examples/inference/SentimentAnalysis.java
@@ -49,7 +49,9 @@ public final class SentimentAnalysis {
     }
 
     public static Classifications predict()
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
         String input = "I like DJL. DJL is the best DL framework!";
         logger.info("input Sentence: {}", input);
diff --git a/examples/src/main/java/ai/djl/examples/inference/UniversalSentenceEncoder.java b/examples/src/main/java/ai/djl/examples/inference/UniversalSentenceEncoder.java
index bb86e23d9..4cc299f42 100644
--- a/examples/src/main/java/ai/djl/examples/inference/UniversalSentenceEncoder.java
+++ b/examples/src/main/java/ai/djl/examples/inference/UniversalSentenceEncoder.java
@@ -56,12 +56,14 @@ public final class UniversalSentenceEncoder {
 
         float[][] embeddings = UniversalSentenceEncoder.predict(inputs);
         for (int i = 0; i < inputs.size(); i++) {
-            logger.info("Embedding for: " + inputs.get(i) + "\n" + Arrays.toString(embeddings[i]));
+            logger.info("Embedding for: {}\n{}", inputs.get(i), Arrays.toString(embeddings[i]));
         }
     }
 
     public static float[][] predict(List<String> inputs)
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
         String modelUrl =
                 "https://storage.googleapis.com/tfhub-modules/google/universal-sentence-encoder/4.tar.gz";
diff --git a/examples/src/main/java/ai/djl/examples/inference/cv/PoseEstimation.java b/examples/src/main/java/ai/djl/examples/inference/cv/PoseEstimation.java
index 1efc59477..3a5866c7b 100644
--- a/examples/src/main/java/ai/djl/examples/inference/cv/PoseEstimation.java
+++ b/examples/src/main/java/ai/djl/examples/inference/cv/PoseEstimation.java
@@ -70,7 +70,9 @@ public final class PoseEstimation {
     }
 
     private static List<Image> predictPeopleInImage(Image img)
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
 
         Criteria<Image, DetectedObjects> criteria =
@@ -106,7 +108,9 @@ public final class PoseEstimation {
     }
 
     private static List<Joints> predictJointsForPeople(List<Image> people)
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
 
         // Use DJL MXNet model zoo model, model can be found:
diff --git a/examples/src/main/java/ai/djl/examples/inference/cv/StyleTransfer.java b/examples/src/main/java/ai/djl/examples/inference/cv/StyleTransfer.java
index 34fef8a89..cc493a9f6 100644
--- a/examples/src/main/java/ai/djl/examples/inference/cv/StyleTransfer.java
+++ b/examples/src/main/java/ai/djl/examples/inference/cv/StyleTransfer.java
@@ -68,7 +68,9 @@ public final class StyleTransfer {
     }
 
     public static Image transfer(Image image, Artist artist)
-            throws IOException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         // Use DJL PyTorch model zoo model, model can be found:
         // https://mlrepo.djl.ai/model/cv/image_generation/ai/djl/pytorch/cyclegan/0.0.1/style_xxxx.zip
diff --git a/examples/src/main/java/ai/djl/examples/inference/nlp/RollingBatch.java b/examples/src/main/java/ai/djl/examples/inference/nlp/RollingBatch.java
index a0aada163..6751f5448 100644
--- a/examples/src/main/java/ai/djl/examples/inference/nlp/RollingBatch.java
+++ b/examples/src/main/java/ai/djl/examples/inference/nlp/RollingBatch.java
@@ -40,14 +40,18 @@ public final class RollingBatch {
     private RollingBatch() {}
 
     public static void main(String[] args)
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         String[] ret = seqBatchSchedulerWithPyTorchContrastive();
         logger.info("{}", ret[0]);
     }
 
     public static String[] seqBatchSchedulerWithPyTorchContrastive()
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         String url = "https://djl-misc.s3.amazonaws.com/test/models/gpt2/gpt2_pt.zip";
 
diff --git a/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java b/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java
index 676188412..1de434576 100644
--- a/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java
+++ b/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java
@@ -42,7 +42,9 @@ public final class TextGeneration {
     private TextGeneration() {}
 
     public static void main(String[] args)
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         String ret1 = generateTextWithPyTorchGreedy();
         logger.info("{}", ret1);
@@ -53,7 +55,9 @@ public final class TextGeneration {
     }
 
     public static String generateTextWithPyTorchGreedy()
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         SearchConfig config = new SearchConfig();
         config.setMaxSeqLength(60);
@@ -88,7 +92,9 @@ public final class TextGeneration {
     }
 
     public static String[] generateTextWithPyTorchContrastive()
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         SearchConfig config = new SearchConfig();
         config.setMaxSeqLength(60);
@@ -120,7 +126,9 @@ public final class TextGeneration {
     }
 
     public static String[] generateTextWithPyTorchBeam()
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         SearchConfig config = new SearchConfig();
         config.setMaxSeqLength(60);
@@ -153,7 +161,9 @@ public final class TextGeneration {
     }
 
     public static String[] generateTextWithOnnxRuntimeBeam()
-            throws ModelNotFoundException, MalformedModelException, IOException,
+            throws ModelNotFoundException,
+                    MalformedModelException,
+                    IOException,
                     TranslateException {
         SearchConfig config = new SearchConfig();
         config.setMaxSeqLength(60);
diff --git a/examples/src/main/java/ai/djl/examples/training/TrainSentimentAnalysis.java b/examples/src/main/java/ai/djl/examples/training/TrainSentimentAnalysis.java
index 4ea222aeb..d89129e7b 100644
--- a/examples/src/main/java/ai/djl/examples/training/TrainSentimentAnalysis.java
+++ b/examples/src/main/java/ai/djl/examples/training/TrainSentimentAnalysis.java
@@ -76,13 +76,17 @@ public final class TrainSentimentAnalysis {
     private TrainSentimentAnalysis() {}
 
     public static void main(String[] args)
-            throws IOException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         TrainSentimentAnalysis.runExample(args);
     }
 
     public static TrainingResult runExample(String[] args)
-            throws IOException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         Arguments arguments = new Arguments().parseArgs(args);
         if (arguments == null) {
diff --git a/examples/src/main/java/ai/djl/examples/training/TrainWithOptimizers.java b/examples/src/main/java/ai/djl/examples/training/TrainWithOptimizers.java
index ba1ea934f..f2db8c8a7 100644
--- a/examples/src/main/java/ai/djl/examples/training/TrainWithOptimizers.java
+++ b/examples/src/main/java/ai/djl/examples/training/TrainWithOptimizers.java
@@ -63,13 +63,19 @@ public final class TrainWithOptimizers {
     private TrainWithOptimizers() {}
 
     public static void main(String[] args)
-            throws IOException, ParseException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ParseException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         TrainWithOptimizers.runExample(args);
     }
 
     public static TrainingResult runExample(String[] args)
-            throws IOException, ParseException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ParseException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         OptimizerArguments arguments =
                 (OptimizerArguments) new OptimizerArguments().parseArgs(args);
diff --git a/extensions/aws-ai/src/main/java/ai/djl/aws/s3/S3Repository.java b/extensions/aws-ai/src/main/java/ai/djl/aws/s3/S3Repository.java
index 898c1a94d..1fc499d5e 100644
--- a/extensions/aws-ai/src/main/java/ai/djl/aws/s3/S3Repository.java
+++ b/extensions/aws-ai/src/main/java/ai/djl/aws/s3/S3Repository.java
@@ -147,7 +147,7 @@ public class S3Repository extends AbstractRepository {
                 return Collections.singletonList(mrl);
             }
         } catch (IOException e) {
-            logger.warn("Failed to scan S3: " + bucket, e);
+            logger.warn("Failed to scan S3: {}", bucket, e);
         }
         return Collections.emptyList();
     }
diff --git a/extensions/hadoop/src/main/java/ai/djl/hadoop/hdfs/HdfsRepository.java b/extensions/hadoop/src/main/java/ai/djl/hadoop/hdfs/HdfsRepository.java
index f010b0760..ddcf82e1f 100644
--- a/extensions/hadoop/src/main/java/ai/djl/hadoop/hdfs/HdfsRepository.java
+++ b/extensions/hadoop/src/main/java/ai/djl/hadoop/hdfs/HdfsRepository.java
@@ -144,7 +144,7 @@ public class HdfsRepository extends AbstractRepository {
                 return Collections.singletonList(mrl);
             }
         } catch (IOException e) {
-            logger.warn("Failed to scan: " + uri.toString(), e);
+            logger.warn("Failed to scan: {}", uri, e);
         }
         return Collections.emptyList();
     }
@@ -157,7 +157,7 @@ public class HdfsRepository extends AbstractRepository {
         resolved = true;
         Artifact artifact = listFiles();
         if (artifact == null) {
-            logger.debug("No object found in hdfs: " + uri);
+            logger.debug("No object found in hdfs: {}", uri);
             return null;
         }
 
diff --git a/extensions/tokenizers/rust/src/lib.rs b/extensions/tokenizers/rust/src/lib.rs
index 6e427f683..af3fec7cd 100644
--- a/extensions/tokenizers/rust/src/lib.rs
+++ b/extensions/tokenizers/rust/src/lib.rs
@@ -48,13 +48,18 @@ pub extern "system" fn Java_ai_djl_huggingface_tokenizers_jni_TokenizersLibrary_
     mut env: JNIEnv<'local>,
     _: JObject,
     input: JString,
+    hf_token: JString,
 ) -> jlong {
     let identifier: String = env
         .get_string(&input)
         .expect("Couldn't get java string!")
         .into();
 
-    let parameters = FromPretrainedParameters::default();
+    let mut parameters = FromPretrainedParameters::default();
+    if !hf_token.is_null() {
+        let hf_token: String = env.get_string(&hf_token).unwrap().into();
+        parameters.auth_token = Some(hf_token);
+    }
     let tokenizer = Tokenizer::from_pretrained(identifier, Some(parameters));
 
     match tokenizer {
diff --git a/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArray.java b/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArray.java
index 715d25033..443dd1392 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArray.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArray.java
@@ -62,6 +62,7 @@ public class RsNDArray extends NativeResource<Long> implements NDArray {
     RsNDArray(RsNDManager manager, long handle, DataType dataType) {
         this(manager, handle, dataType, null);
     }
+
     /**
      * Constructs a Rust {@code NDArray} from a native handle (internal. Use {@link NDManager}
      * instead) with the data that is hold on Java side.
diff --git a/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArrayEx.java b/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArrayEx.java
index 453658a86..f30037bf5 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArrayEx.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/engine/rust/RsNDArrayEx.java
@@ -402,6 +402,7 @@ public class RsNDArrayEx implements NDArrayEx {
             NDArray input, Shape normalizedShape, NDArray gamma, NDArray beta, float eps) {
         throw new UnsupportedOperationException("Not implemented");
     }
+
     /** {@inheritDoc} */
     @Override
     public NDList batchNorm(
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizer.java b/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizer.java
index 8d32ccb4b..177366faf 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizer.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizer.java
@@ -112,8 +112,12 @@ public final class HuggingFaceTokenizer extends NativeResource<Long> implements
     public static HuggingFaceTokenizer newInstance(String identifier, Map<String, String> options) {
         Ec2Utils.callHome("Huggingface");
         LibUtils.checkStatus();
+        String autoToken = Utils.getEnvOrSystemProperty("HF_TOKEN");
+        if (options != null) {
+            autoToken = options.getOrDefault("hf_token", autoToken);
+        }
 
-        long handle = TokenizersLibrary.LIB.createTokenizer(identifier);
+        long handle = TokenizersLibrary.LIB.createTokenizer(identifier, autoToken);
         return new HuggingFaceTokenizer(handle, options);
     }
 
@@ -543,12 +547,12 @@ public final class HuggingFaceTokenizer extends NativeResource<Long> implements
         if (padding == PaddingStrategy.MAX_LENGTH || isTruncate) {
             if (maxLength == -1) {
                 logger.warn(
-                        "maxLength is not explicitly specified, use modelMaxLength: "
-                                + modelMaxLength);
+                        "maxLength is not explicitly specified, use modelMaxLength: {}",
+                        modelMaxLength);
                 maxLength = modelMaxLength;
             } else if (maxLength > modelMaxLength) {
                 logger.warn(
-                        "maxLength is greater then modelMaxLength, change to: " + modelMaxLength);
+                        "maxLength is greater then modelMaxLength, change to: {}", modelMaxLength);
                 maxLength = modelMaxLength;
             }
 
@@ -560,12 +564,11 @@ public final class HuggingFaceTokenizer extends NativeResource<Long> implements
                         newMaxLength -= padToMultipleOf;
                     }
                     logger.warn(
-                            "maxLength ("
-                                    + maxLength
-                                    + ") is not a multiple of padToMultipleOf ("
-                                    + padToMultipleOf
-                                    + "), change to: "
-                                    + newMaxLength);
+                            "maxLength ({}) is not a multiple of padToMultipleOf ({}), change to:"
+                                    + " {}",
+                            maxLength,
+                            padToMultipleOf,
+                            newMaxLength);
                     maxLength = newMaxLength;
                 }
             }
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/jni/TokenizersLibrary.java b/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/jni/TokenizersLibrary.java
index 63a2f96fd..8acfa7d04 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/jni/TokenizersLibrary.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/huggingface/tokenizers/jni/TokenizersLibrary.java
@@ -20,7 +20,7 @@ public final class TokenizersLibrary {
 
     private TokenizersLibrary() {}
 
-    public native long createTokenizer(String identifier);
+    public native long createTokenizer(String identifier, String authToken);
 
     public native long createTokenizerFromString(String json);
 
diff --git a/model-zoo/src/main/java/ai/djl/basicmodelzoo/cv/classification/MobileNetV2.java b/model-zoo/src/main/java/ai/djl/basicmodelzoo/cv/classification/MobileNetV2.java
index fe5e2d09f..4a817cd0d 100644
--- a/model-zoo/src/main/java/ai/djl/basicmodelzoo/cv/classification/MobileNetV2.java
+++ b/model-zoo/src/main/java/ai/djl/basicmodelzoo/cv/classification/MobileNetV2.java
@@ -44,6 +44,7 @@ public final class MobileNetV2 {
     public static final int MULTILENGTH = 7;
 
     private MobileNetV2() {}
+
     /**
      * Builds a {@link Block} that represent an inverted residual Unit used in the implementation of
      * the MobileNetV2 Model.
diff --git a/tools/gradle/java-formatter.gradle b/tools/gradle/java-formatter.gradle
index 5bf1b92f3..426939803 100644
--- a/tools/gradle/java-formatter.gradle
+++ b/tools/gradle/java-formatter.gradle
@@ -6,7 +6,7 @@ buildscript {
         }
     }
     dependencies {
-        classpath 'com.google.googlejavaformat:google-java-format:1.15.0'
+        classpath 'com.google.googlejavaformat:google-java-format:1.22.0'
     }
 }
 


Test patch:
diff --git a/engines/pytorch/pytorch-engine/src/test/java/ai/djl/pytorch/integration/ProfilerTest.java b/engines/pytorch/pytorch-engine/src/test/java/ai/djl/pytorch/integration/ProfilerTest.java
index 88f1e9cd3..6c60bf15e 100644
--- a/engines/pytorch/pytorch-engine/src/test/java/ai/djl/pytorch/integration/ProfilerTest.java
+++ b/engines/pytorch/pytorch-engine/src/test/java/ai/djl/pytorch/integration/ProfilerTest.java
@@ -43,7 +43,9 @@ public class ProfilerTest {
 
     @Test
     public void testProfiler()
-            throws MalformedModelException, ModelNotFoundException, IOException,
+            throws MalformedModelException,
+                    ModelNotFoundException,
+                    IOException,
                     TranslateException {
         try (NDManager manager = NDManager.newBaseManager()) {
             ImageClassificationTranslator translator =
diff --git a/examples/src/test/java/ai/djl/examples/inference/StyleTransferTest.java b/examples/src/test/java/ai/djl/examples/inference/StyleTransferTest.java
index 8b4d4510a..1981cda76 100644
--- a/examples/src/test/java/ai/djl/examples/inference/StyleTransferTest.java
+++ b/examples/src/test/java/ai/djl/examples/inference/StyleTransferTest.java
@@ -30,7 +30,9 @@ public class StyleTransferTest {
 
     @Test
     public void testStyleTransfer()
-            throws IOException, ModelNotFoundException, MalformedModelException,
+            throws IOException,
+                    ModelNotFoundException,
+                    MalformedModelException,
                     TranslateException {
         TestRequirements.engine("PyTorch");
 
diff --git a/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java b/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java
index 4395ddf1a..e88efefc0 100644
--- a/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java
+++ b/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java
@@ -81,7 +81,9 @@ public class CookingStackExchangeTest {
 
     @Test
     public void testTextClassification()
-            throws IOException, MalformedModelException, ModelNotFoundException,
+            throws IOException,
+                    MalformedModelException,
+                    ModelNotFoundException,
                     TranslateException {
         Criteria<String, Classifications> criteria =
                 Criteria.builder()
diff --git a/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizerTest.java b/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizerTest.java
index 1b0883dfb..ead688539 100644
--- a/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizerTest.java
+++ b/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/HuggingFaceTokenizerTest.java
@@ -14,6 +14,7 @@
 package ai.djl.huggingface.tokenizers;
 
 import ai.djl.huggingface.tokenizers.jni.CharSpan;
+import ai.djl.testing.TestRequirements;
 import ai.djl.training.util.DownloadUtils;
 import ai.djl.util.PairList;
 import ai.djl.util.Utils;
@@ -541,4 +542,17 @@ public class HuggingFaceTokenizerTest {
             Assert.assertEquals(tokens, expected);
         }
     }
+
+    @Test
+    public void testAuthToken() {
+        TestRequirements.notOffline();
+        System.setProperty("HF_TOKEN", "test_token");
+        try {
+            HuggingFaceTokenizer.newInstance("mistralai/Mixtral-8x7B-v0.1");
+        } catch (RuntimeException ignore) {
+            // access denied
+        } finally {
+            System.clearProperty("HF_TOKEN");
+        }
+    }
 }
diff --git a/integration/src/main/java/ai/djl/integration/IntegrationTest.java b/integration/src/main/java/ai/djl/integration/IntegrationTest.java
index f3871ff27..9f9bcf6e1 100644
--- a/integration/src/main/java/ai/djl/integration/IntegrationTest.java
+++ b/integration/src/main/java/ai/djl/integration/IntegrationTest.java
@@ -373,8 +373,7 @@ public class IntegrationTest {
                     logger.trace("", e.getCause());
                     result = TestResult.UNSUPPORTED;
                 } else {
-                    logger.error("Test {}.{} FAILED", getName(), method.getName());
-                    logger.error("", e.getCause());
+                    logger.error("Test {}.{} FAILED", getName(), method.getName(), e.getCause());
                     result = TestResult.FAILED;
                 }
             } finally {
diff --git a/integration/src/main/java/ai/djl/integration/tests/model_zoo/classification/ResnetTest.java b/integration/src/main/java/ai/djl/integration/tests/model_zoo/classification/ResnetTest.java
index 25be89ae7..6133c6ed5 100644
--- a/integration/src/main/java/ai/djl/integration/tests/model_zoo/classification/ResnetTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/model_zoo/classification/ResnetTest.java
@@ -138,7 +138,9 @@ public class ResnetTest {
 
     @Test
     public void testLoadPredict()
-            throws IOException, ModelNotFoundException, TranslateException,
+            throws IOException,
+                    ModelNotFoundException,
+                    TranslateException,
                     MalformedModelException {
         try (ZooModel<Image, Classifications> model = getModel()) {
             NoopTranslator translator = new NoopTranslator(Batchifier.STACK);