code: def test_sha1_delete(sha1_store, compress):
      """Testing the delete() API: with ref counting behavior."""
      os.chdir(TESTING_STORE_DIR)
  
      # Add once and delete, second delete should throw an exception.
      tensor = torch.ones(30, 50)
      sha1 = sha1_store.add(tensor, compress)
      sha1_store.delete(sha1)
      with pytest.raises(ValueError):
          sha1_store.delete(sha1)
  
      # Add multiple times and delete should match that.
      state_dict = nn.Sequential(
          nn.Linear(10, 10), nn.Linear(10, 20)
      ).state_dict()
      sha1 = sha1_store.add(state_dict, compress)
      for i in range(3):
          new_sha1 = sha1_store.add(state_dict, compress)
          assert sha1 == new_sha1, f"{sha1} vs. {new_sha1}"
      for i in range(4):
          sha1_store.delete(sha1)
      with pytest.raises(ValueError):
          sha1_store.delete(sha1)
  
file_path: fairscale/tests/experimental/wgit/test_sha1_store.py
imports: import os
  from pathlib import Path
  import shutil
  import sys
  import pytest
  import torch
  from torch import nn
  from fairscale.experimental.wgit.sha1_store import SHA1_Store
  from fairscale.fair_dev.testing.testing import objects_are_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_sha1_delete(sha1_store, compress) without return types