docstr: Merges attn_head_size dim and num_attn_heads dim into hidden_size
docstr_tok: ["Merges","attn_head_size","dim","and","num_attn_heads","dim","into","hidden_size"]
code: def _merge_heads(self, tensor, num_heads, attn_head_size):
      """
      Merges attn_head_size dim and num_attn_heads dim into hidden_size
      """
      tensor = tensor.permute(0, 2, 1, 3).contiguous()
      new_shape = tensor.size()[:-2] + (num_heads * attn_head_size,)
      return tensor.view(new_shape)
  
imports: import math
  import os
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.cuda.amp import autocast
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import Conv1D, find_pruneable_heads_and_indices, prune_conv1d_layer
  from ...utils import ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_decision_transformer import DecisionTransformerConfig
label_desc: Use image node_id 6 for calling the DecisionTransformerGPT2Attention obj's underlying member method code with example usage: obj._merge_heads(tensor, num_heads, attn_head_size) and returns: tensor