code: def linear_mask(module_masks, mask, shape):
      """
      Infer input and output shape from weight mask with limitations:
      Only support infer input mask
  
      Parameters
      ----------
      module_masks : ModuleMasks
          The ModuleMasks instance of the Linear
      mask : dict
          The mask of its weights, from the user provided mask file
      shape: dict
          Shape of its input and output tensors
      Returns
      -------
      CoarseMask, CoarseMask
          The mask of its input tensor, the mask of its output tensor
      """
  
      assert "weight" in mask
      num_input_dim = len(shape["in_shape"])
  
      # Input data of Linear module can have multiple dimensions.
      # here we only support infer coarse mask on the first dimension (dimension 0)
      nonzero_index = torch.nonzero(
          mask["weight"].sum(0), as_tuple=True
      )[0]
  
      # infer shape of input tensor
      input_cmask = CoarseMask(num_dim=num_input_dim)
      input_cmask.add_index_mask(
          dim=num_input_dim - 1, index=nonzero_index
      )
  
      module_masks.set_input_mask(input_cmask)
      return input_cmask, None
  
imports: import logging
  import torch
label_desc: Use image node_id 20 for calling a global function with example usage: linear_mask(module_masks, mask, shape) and returns: input_cmask,  None