code: def nanmedian(
      values,
      *,
      axis: AxisInt | None = None,
      skipna: bool = True,
      mask=None,
  ):
      """
      Parameters
      ----------
      values : ndarray
      axis : int, optional
      skipna : bool, default True
      mask : ndarray[bool], optional
          nan-mask if known
  
      Returns
      -------
      result : float
          Unless input is a float array, in which case use the same
          precision as the input array.
  
      Examples
      --------
      >>> from pandas.core import nanops
      >>> s = pd.Series([1, np.nan, 2, 2])
      >>> nanops.nanmedian(s)
      2.0
      """
  
      def get_median(x, _mask=None):
          if _mask is None:
              _mask = notna(x)
          else:
              _mask = ~_mask
          if not skipna and not _mask.all():
              return np.nan
          with warnings.catch_warnings():
              # Suppress RuntimeWarning about All-NaN slice
              warnings.filterwarnings(
                  "ignore", "All-NaN slice encountered", RuntimeWarning
              )
              res = np.nanmedian(x[_mask])
          return res
  
      values, mask, dtype, _, _ = _get_values(
          values, skipna, mask=mask, fill_value=0
      )
      if not is_float_dtype(values.dtype):
          try:
              values = values.astype("f8")
          except ValueError as err:
              # e.g. "could not convert string to float: 'a'"
              raise TypeError(str(err)) from err
      if mask is not None:
          values[mask] = np.nan
  
      notempty = values.size
  
      # an array from a frame
      if values.ndim > 1 and axis is not None:
          # there's a non-empty array to apply over otherwise numpy raises
          if notempty:
              if not skipna:
                  res = np.apply_along_axis(get_median, axis, values)
  
              else:
                  # fastpath for the skipna case
                  with warnings.catch_warnings():
                      # Suppress RuntimeWarning about All-NaN slice
                      warnings.filterwarnings(
                          "ignore",
                          "All-NaN slice encountered",
                          RuntimeWarning,
                      )
                      res = np.nanmedian(values, axis)
  
          else:
              # must return the correct shape, but median is not defined for the
              # empty set so return nans of shape "everything but the passed axis"
              # since "axis" is where the reduction would occur if we had a nonempty
              # array
              res = get_empty_reduction_result(
                  values.shape, axis, np.float_, np.nan
              )
  
      else:
          # otherwise return a scalar value
          res = get_median(values, mask) if notempty else np.nan
      return _wrap_results(res, dtype)
  
imports: from __future__ import annotations
  import functools
  import itertools
  import operator
  from typing import Any, Callable, cast
  import warnings
  import numpy
  from pandas._config import get_option
  from pandas._libs import NaT, NaTType, iNaT, lib
  from pandas._typing import ArrayLike, AxisInt, CorrelationMethod, Dtype, DtypeObj, F, Scalar, Shape, npt
  from pandas.compat._optional import import_optional_dependency
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.common import is_any_int_dtype, is_bool_dtype, is_complex, is_datetime64_any_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, is_numeric_dtype, is_object_dtype, is_scalar, is_timedelta64_dtype, needs_i8_conversion, pandas_dtype
  from pandas.core.dtypes.dtypes import PeriodDtype
  from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna
  from pandas.core.construction import extract_array
label_desc: Use image node_id 17 for calling a global function with example usage: nanmedian(values) and returns: _wrap_results, res, np