def unregister_counter_nonzero(network):
  """
  Unregister nonzero counter hooks
  :param network: The network previously registered via `register_nonzero_counter`
  """
  if not hasattr(network, "__counter_nonzero_handles__"):
    raise ValueError("register_counter_nonzero was not called for this network")

  for h in network.__counter_nonzero_handles__:
    h.remove()

  delattr(network, "__counter_nonzero_handles__")
  for module in network.modules():
    if hasattr(module, "__counter_nonzero__"):
      delattr(module, "__counter_nonzero__")
Unregister nonzero counter hooks
  :param network: The network previously registered via `register_nonzero_counter`