code: def _nanmedian(input, axis, keepdims):
      dtype = input.dtype
      temp = input.to(torch.float64)
      num_dim = len(temp.size())
      keepdim_shape = list(temp.size())
      q = 0.5
  
      axis = [axis] if isinstance(axis, int) else list(axis)
  
      for i in axis:
          keepdim_shape[i] = 1
      axis = [num_dim + x if x < 0 else x for x in axis]
      axis.sort()
      dimension = len(temp.size())
      while len(axis) > 0:
          axis1 = axis[0]
          for axis2 in range(axis1 + 1, dimension):
              temp = torch.transpose(temp, axis1, axis2)
              axis1 = axis2
          axis = [x - 1 for x in axis]
          axis.pop(0)
          dimension = dimension - 1
      temp = torch.flatten(temp, start_dim=dimension - len(axis))
      ret = torch.nanquantile(
          temp, q, dim=-1, keepdim=keepdims, interpolation="midpoint"
      )
      if keepdims:
          keepdim_shape = tuple(keepdim_shape)
          ret = ret.reshape(keepdim_shape)
  
      if dtype in [torch.int32, torch.int64, torch.float64]:
          ret = torch.asarray(ret, dtype=torch.float64)
      elif dtype in [torch.float16, torch.bfloat16]:
          ret = torch.asarray(ret, dtype=torch.float16)
      else:
          ret = torch.asarray(ret, dtype=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 13 for calling a global function with example usage: _nanmedian(input, axis, keepdims) and returns: ret