code: def compute_valid_1d_patterns(m, n):
      # Early exit if patterns was already created.
      global valid_m4n2_1d_patterns
  
      if m == 4 and n == 2 and valid_m4n2_1d_patterns is not None:
          return valid_m4n2_1d_patterns
      patterns = torch.zeros(m)
      patterns[:n] = 1
      valid_patterns = torch.tensor(
          list(set(permutations(patterns.tolist())))
      )
      if m == 4 and n == 2:
          valid_m4n2_1d_patterns = valid_patterns
      return valid_patterns
  
file_path: apex/apex/contrib/sparsity/sparse_masklib.py
imports: import sys
  import torch
  import numpy
  import collections
  from itertools import permutations
label_desc: Use image node_id 3 for calling a global function with example usage: compute_valid_1d_patterns(m, n) and returns: valid_patterns, valid_m4n2_1d_patterns