code: def mn_1d_best(matrix, m, n):
      # Find all possible patterns.
      patterns = compute_valid_1d_patterns(m, n).cuda()
  
      # Find the best m:n pattern (sum of non-masked weights).
      mask = torch.cuda.IntTensor(matrix.shape).fill_(1).view(-1, m)
      mat, shape = reshape_1d(matrix, m)
      pmax = torch.argmax(torch.matmul(mat.abs(), patterns.t()), dim=1)
      mask[:] = patterns[pmax[:]]
      mask = mask.view(matrix.shape)
      return mask
  
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 4 for calling a global function with example usage: mn_1d_best(matrix, m, n) and returns: mask