code: def _deaugment_averaging(
      x: Tensor, reduction: MaybeStrOrCallable
  ) -> Tensor:
      """
      Average predictions of TTA-ed model.
      This function assumes TTA dimension is 0, e.g [T, B, C, Ci, Cj, ..]
  
      Args:
          x: Input tensor of shape [T, B, ... ]
          reduction: Reduction mode ("sum", "mean", "gmean", "hmean", function, None)
  
      Returns:
          Tensor of shape [B, C, Ci, Cj, ..]
      """
      if reduction == "mean":
          x = x.mean(dim=0)
      elif reduction == "sum":
          x = x.sum(dim=0)
      elif reduction in {"gmean", "geometric_mean"}:
          x = F.geometric_mean(x, dim=0)
      elif reduction in {"hmean", "harmonic_mean"}:
          x = F.harmonic_mean(x, dim=0)
      elif reduction in {"harmonic1p"}:
          x = F.harmonic1p_mean(x, dim=0)
      elif reduction == "logodd":
          x = F.logodd_mean(x, dim=0)
      elif reduction == "log1p":
          x = F.log1p_mean(x, dim=0)
      elif callable(reduction):
          x = reduction(x, dim=0)
      elif reduction in {None, "None", "none"}:
          pass
      else:
          raise KeyError(f"Unsupported reduction mode {reduction}")
  
      return x
  
imports: from collections import defaultdict
  from functools import partial
  from typing import Tuple, List, Optional, Union, Callable, Dict, Mapping
  import torch
  from torch import Tensor, nn
  from .None import functional
  from ..utils.support import pytorch_toolbelt_deprecated
label_desc: Use image node_id 2 for calling a global function with example usage: _deaugment_averaging(x, reduction) and returns: x