class_docstr: Prune (currently unpruned) units in a tensor at random.
  
  Args:
      name (str): parameter name within ``module`` on which pruning
          will act.
      amount (int or float): quantity of parameters to prune.
          If ``float``, should be between 0.0 and 1.0 and represent the
          fraction of parameters to prune. If ``int``, it represents the
          absolute number of parameters to prune.
class_docstr_tok: ["Prune","(","currently","unpruned",")","units","in","a","tensor","at","random",".","Args",":","name","(","str",")",":","parameter","name","within","``","module","``","on","which","pruning","will","act",".","amount","(","int","or","float",")",":","quantity","of","parameters","to","prune",".","If","``","float","``",",","should","be","between","0.0","and","1.0","and","represent","the","fraction","of","parameters","to","prune",".","If","``","int","``",",","it","represents","the","absolute","number","of","parameters","to","prune","."]
code: def compute_mask(self, t, default_mask):
      # Check that the amount of units to prune is not > than the number of
      # parameters in t
      tensor_size = t.nelement()
      # Compute number of units to prune: amount if int,
      # else amount * tensor_size
      nparams_toprune = _compute_nparams_toprune(
          self.amount, tensor_size
      )
      # This should raise an error if the number of units to prune is larger
      # than the number of units in the tensor
      _validate_pruning_amount(nparams_toprune, tensor_size)
  
      mask = default_mask.clone(memory_format=torch.contiguous_format)
  
      if nparams_toprune != 0:  # k=0 not supported by torch.kthvalue
          prob = torch.rand_like(t)
          topk = torch.topk(prob.view(-1), k=nparams_toprune)
          mask.view(-1)[topk.indices] = 0
  
      return mask
  
imports: import numbers
  from abc import ABC, abstractmethod
  from collections.abc import Iterable
  from typing import Tuple
  import torch
label_desc: Use image node_id 2 for calling the RandomUnstructured obj's underlying member method code with example usage: obj.compute_mask(t, default_mask) and returns: mask