code: def replace_prelu(prelu, masks):
      """
      Parameters
      ----------
      module : torch.nn.PReLU
          The prelu module to be replace
      masks : tuple of masks
          The input/output/weight masks of the target module
  
      Returns
      -------
      torch.nn.PReLU
          The new prelu module
      """
      in_masks, output_mask, weight_mask = masks
      if len(in_masks) != 1:
          raise InputsNumberError()
      if not isinstance(output_mask, torch.Tensor):
          raise OutputTypeError(type(output_mask), torch.Tensor)
  
      in_mask = in_masks[0]
      weight_mask = weight_mask["weight"]
      if weight_mask.size(0) == 1:
          return prelu
      pruned_in, remained_in = convert_to_coarse_mask(in_mask, 1)
      pruned_out, remained_out = convert_to_coarse_mask(output_mask, 1)
      n_remained_in = weight_mask.size(0) - pruned_in.size(0)
      n_remained_out = weight_mask.size(0) - pruned_out.size(0)
      remained_in, remained_out = remained_in.to(
          prelu.weight.device
      ), remained_out.to(prelu.weight.device)
      if n_remained_in != n_remained_out:
          raise ShapeMisMatchError()
  
      if n_remained_in == 0:
          return torch.nn.Identity()
      new_prelu = torch.nn.PReLU(n_remained_in)
      new_prelu.weight.data = torch.index_select(
          prelu.weight.data, 0, remained_in
      )
      return new_prelu
  
file_path: nni/nni/compression/speedup/replacement.py
imports: import logging
  import math
  import torch
  import torch.nn
  from .error_code import EmptyLayerError, ShapeMisMatchError, InputsNumberError, OutputTypeError, UnBalancedGroupError
label_desc: Use image node_id 4 for calling a global function with example usage: replace_prelu(prelu, masks) and returns: new_prelu, prelu, torch