code: def nanmedian(
      input: torch.Tensor,
      /,
      *,
      axis: Optional[Union[Tuple[int], int]] = None,
      keepdims: bool = False,
      overwrite_input: bool = False,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      if overwrite_input:
          copied_input = input.clone()
          if axis is None:
              copied_input = copied_input.flatten()
  
              ret = torch.nanquantile(
                  copied_input.double(),
                  0.5,
                  dim=-1,
                  keepdim=keepdims,
                  interpolation="midpoint",
              )
  
              if input.dtype in [
                  torch.int32,
                  torch.int64,
                  torch.float64,
              ]:
                  ret = ret.to(torch.float64)
              elif input.dtype in [torch.float16, torch.bfloat16]:
                  ret = ret.to(torch.float16)
              else:
                  ret = ret.to(torch.float32)
              return ret
  
          return _nanmedian(copied_input, axis, keepdims)
  
      else:
          if axis is None:
              input = input.flatten()
  
              ret = torch.nanquantile(
                  input.double(),
                  0.5,
                  dim=-1,
                  keepdim=keepdims,
                  interpolation="midpoint",
              )
  
              if input.dtype in [
                  torch.int32,
                  torch.int64,
                  torch.float64,
              ]:
                  ret = ret.to(torch.float64)
              elif input.dtype in [torch.float16, torch.bfloat16]:
                  ret = ret.to(torch.float16)
              else:
                  ret = ret.to(torch.float32)
              return ret
  
          return _nanmedian(input, axis, keepdims)
  
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 14 for calling a global function with example usage: nanmedian() and returns: _nanmedian, _nanmedian, ret, ret