docstr: Call this method to determine if sparsity is enabled in the model.
  The typical use case is right after checkpoint has been loaded.
docstr_tok: ["Call","this","method","to","determine","if","sparsity","is","enabled","in","the","model",".","The","typical","use","case","is","right","after","checkpoint","has","been","loaded","."]
code: def is_sparsity_enabled(cls):
      """Call this method to determine if sparsity is enabled in the model.
      The typical use case is right after checkpoint has been loaded.
      """
      total, sp100, sp50 = 0, 0, 0
      for (
          module_name,
          module,
          p_name,
          p,
          mask,
          pruned,
      ) in cls.__sparse_parameters:
          total += 1
          mask_sum = mask.sum()
          mask_numel = mask.numel()
          if mask_sum == mask_numel:
              sp100 += 1
          elif mask_sum * 2 == mask_numel:
              sp50 += 1
  
      assert (
          total == sp100 or total == sp50
      ), "Inconsistent model sparsity"
      if total == sp100:
          return False
      elif total == sp50:
          return True
  
file_path: apex/apex/contrib/sparsity/asp.py
imports: import types
  import torch
  from .sparse_masklib import create_mask
  from .permutation_lib import Permutation
  import json
  import os
  import string
  import time
label_desc: Use image node_id 6 for calling the ASP obj's underlying member method code with example usage: obj.is_sparsity_enabled(cls) and returns: False, True