code: def _maybe_get_mask(
      values: np.ndarray,
      skipna: bool,
      mask: npt.NDArray[np.bool_] | None,
  ) -> npt.NDArray[np.bool_] | None:
      """
      Compute a mask if and only if necessary.
  
      This function will compute a mask iff it is necessary. Otherwise,
      return the provided mask (potentially None) when a mask does not need to be
      computed.
  
      A mask is never necessary if the values array is of boolean or integer
      dtypes, as these are incapable of storing NaNs. If passing a NaN-capable
      dtype that is interpretable as either boolean or integer data (eg,
      timedelta64), a mask must be provided.
  
      If the skipna parameter is False, a new mask will not be computed.
  
      The mask is computed using isna() by default. Setting invert=True selects
      notna() as the masking function.
  
      Parameters
      ----------
      values : ndarray
          input array to potentially compute mask for
      skipna : bool
          boolean for whether NaNs should be skipped
      mask : Optional[ndarray]
          nan-mask if known
  
      Returns
      -------
      Optional[np.ndarray[bool]]
      """
      if mask is None:
          if is_bool_dtype(values.dtype) or is_integer_dtype(
              values.dtype
          ):
              # Boolean data cannot contain nulls, so signal via mask being None
              return None
  
          if skipna or needs_i8_conversion(values.dtype):
              mask = isna(values)
  
      return mask
  
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 5 for calling a global function with example usage: _maybe_get_mask(values, skipna, mask) and returns: mask, None