code: def average_torch_dicts(list_of_dicts: List[Dict]) -> Dict:
      """Average values of a list of dicts with torch tensors."""
      average_dict = dict()
      for key in list_of_dicts[0].keys():
          average_dict[key] = torch.mean(
              torch.stack([d[key] for d in list_of_dicts]), axis=0
          )
      return average_dict
  
imports: import gc
  import random
  import warnings
  from contextlib import contextmanager
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import pad_sequence
  from transformers import top_k_top_p_filtering
  from .import_utils import is_npu_available, is_xpu_available
label_desc: Use image node_id 13 for calling a global function with example usage: average_torch_dicts(list_of_dicts) and returns: average_dict