code: def test_hf_model_hub():
      print("Testing HF model hub started")
      torch.manual_seed(0)
      np.random.seed(0)
      X_train, X_test, y_train, y_test = get_classification_data()
  
      hf_api = HfApi()
      hub_pickle_storer = HfHubStorage(
          hf_api,
          path_in_repo=MODEL_NAME,
          repo_id=REPO_NAME,
          token=TOKEN,
          verbose=1,
      )
      hub_params_storer = HfHubStorage(
          hf_api,
          path_in_repo=WEIGHTS_NAME,
          repo_id=REPO_NAME,
          token=TOKEN,
          verbose=1,
          local_storage="my-model-weights.pt",
      )
      checkpoint = TrainEndCheckpoint(
          f_pickle=hub_pickle_storer,
          f_params=hub_params_storer,
          f_optimizer=None,
          f_criterion=None,
          f_history=None,
      )
  
      net = NeuralNetClassifier(
          ClassifierModule,
          lr=0.1,
          device=DEVICE,
          iterator_train__shuffle=True,
          callbacks=[checkpoint],
      )
  
      net.fit(X_train, y_train)
      assert accuracy_score(y_test, net.predict(X_test)) > 0.7
      print(hub_pickle_storer.latest_url_)
  
      path = hf_hub_download(
          REPO_NAME, MODEL_NAME, use_auth_token=TOKEN
      )
      with open(path, "rb") as f:
          net_loaded = pickle.load(f)
  
      with torch.inference_mode():
          assert np.allclose(
              net.predict_proba(X_test),
              net_loaded.predict_proba(X_test),
          )
  
      path = hf_hub_download(
          REPO_NAME, WEIGHTS_NAME, use_auth_token=TOKEN
      )
      with open(path, "rb") as f:
          weights_loaded = torch.load(f)
  
      weights = dict(net.module_.named_parameters())
      assert weights.keys() == weights_loaded.keys()
      for key in weights.keys():
          torch.testing.assert_close(weights[key], weights[key])
  
      print("Testing HF model hub completed")
  
imports: import os
  import pickle
  from contextlib import contextmanager
  import numpy
  import torch
  from huggingface_hub import HfApi, create_repo, hf_hub_download
  from sklearn.datasets import fetch_20newsgroups, make_classification
  from sklearn.metrics import accuracy_score
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import Pipeline
  from torch import nn
  from transformers import AutoModelForSequenceClassification
  from skorch import NeuralNetClassifier
  from skorch.hf import HuggingfacePretrainedTokenizer
  from skorch.callbacks import TrainEndCheckpoint
  from skorch.hf import HfHubStorage
label_desc: Use image node_id 6 for calling a global function with example usage: test_hf_model_hub() without return types