code: def median(
      input: torch.Tensor,
      /,
      *,
      axis: Optional[Union[Tuple[int], int]] = None,
      keepdims: bool = False,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      if isinstance(axis, tuple):
          if len(axis) == 1:
              axis = axis[0]
      ret = quantile(
          input,
          0.5,
          axis=axis,
          keepdims=keepdims,
          interpolation="midpoint",
      )
      if input.dtype in [torch.int64, torch.float64]:
          ret = ret.to(torch.float64)
      elif input.dtype in [torch.float16, torch.bfloat16]:
          ret = ret.to(input.dtype)
      else:
          ret = ret.to(torch.float32)
      return ret
  
imports: from typing import Optional, Union, Tuple, Sequence
  import torch
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from .None import backend_version
  import ivy
  from ..statistical import _infer_dtype
  from copy import deepcopy
label_desc: Use image node_id 2 for calling a global function with example usage: median() and returns: ret