code: def prune_heads(self, heads):
      if len(heads) == 0:
          return
      heads, index = find_pruneable_heads_and_indices(
          heads,
          self.self_attn.num_attention_heads,
          self.self_attn.attention_head_size,
          self.pruned_heads,
      )
  
      # Prune linear layers
      self.self_attn.q_proj = prune_linear_layer(
          self.self_attn.q_proj, index
      )
      self.self_attn.k_proj = prune_linear_layer(
          self.self_attn.k_proj, index
      )
      self.self_attn.v_proj = prune_linear_layer(
          self.self_attn.v_proj, index
      )
      self.out_proj = prune_linear_layer(self.out_proj, index, dim=1)
  
      # Update hyper params and store pruned heads
      self.self_attn.num_attention_heads = (
          self.self_attn.num_attention_heads - len(heads)
      )
      self.self_attn.all_head_size = (
          self.self_attn.attention_head_size
          * self.self_attn.num_attention_heads
      )
      self.pruned_heads = self.pruned_heads.union(heads)
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn, tensor
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_ernie_m import ErnieMConfig
label_desc: Use image node_id 2 for calling the ErnieMAttention obj's underlying member method code with example usage: obj.prune_heads(heads) without return types