code: def _nanargminmax(
      values: np.ndarray, mask: npt.NDArray[np.bool_], func
  ) -> int:
      """
      See nanargminmax.__doc__.
      """
      idx = np.arange(values.shape[0])
      non_nans = values[~mask]
      non_nan_idx = idx[~mask]
  
      return non_nan_idx[func(non_nans)]
  
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import TYPE_CHECKING, Callable, DefaultDict, Hashable, Iterable, Sequence, cast
  import numpy
  from pandas._libs import algos, hashtable, lib
  from pandas._libs.hashtable import unique_label_indices
  from pandas._typing import AxisInt, IndexKeyFunc, Level, NaPosition, Shape, SortKind, npt
  from pandas.core.dtypes.common import ensure_int64, ensure_platform_int, is_extension_array_dtype
  from pandas.core.dtypes.generic import ABCMultiIndex, ABCRangeIndex
  from pandas.core.dtypes.missing import isna
  from pandas.core.construction import extract_array
label_desc: Use image node_id 11 for calling a global function with example usage: _nanargminmax(values, mask, func) and returns: non_nan_idx