code: def test_models_huggingface_hub(
      arch_name, task_name, dummy_model_id, tmpdir
  ):
      with tempfile.TemporaryDirectory() as tmp_dir:
          model = (
              models.__dict__[task_name]
              .__dict__[arch_name](pretrained=True)
              .eval()
          )
  
          _save_model_and_config_for_hf_hub(
              model, arch=arch_name, task=task_name, save_dir=tmp_dir
          )
  
          assert hasattr(model, "cfg")
          assert len(os.listdir(tmp_dir)) == 2
          assert os.path.exists(tmp_dir + "/pytorch_model.bin")
          assert os.path.exists(tmp_dir + "/config.json")
          tmp_config = json.load(open(tmp_dir + "/config.json"))
          assert arch_name == tmp_config["arch"]
          assert task_name == tmp_config["task"]
          assert all(
              key in model.cfg.keys() for key in tmp_config.keys()
          )
  
          # test from hub
          hub_model = from_hub(repo_id=dummy_model_id)
          assert isinstance(hub_model, type(model))
  
file_path: doctr/tests/pytorch/test_models_factory.py
imports: import json
  import os
  import tempfile
  import pytest
  from doctr import models
  from doctr.models.factory import _save_model_and_config_for_hf_hub, from_hub, push_to_hf_hub
label_desc: Use image node_id 2 for calling a global function with example usage: test_models_huggingface_hub(arch_name, task_name, dummy_model_id, tmpdir) without return types