code: def ensure_python_int(value: int | np.integer) -> int:
      """
      Ensure that a value is a python int.
  
      Parameters
      ----------
      value: int or numpy.integer
  
      Returns
      -------
      int
  
      Raises
      ------
      TypeError: if the value isn't an int or can't be converted to one.
      """
      if not (is_integer(value) or is_float(value)):
          if not is_scalar(value):
              raise TypeError(
                  f"Value needs to be a scalar value, was type {type(value).__name__}"
              )
          raise TypeError(f"Wrong type {type(value)} for value {value}")
      try:
          new_value = int(value)
          assert new_value == value
      except (TypeError, ValueError, AssertionError) as err:
          raise TypeError(
              f"Wrong type {type(value)} for value {value}"
          ) from err
      return new_value
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any, Callable
  import warnings
  import numpy
  from pandas._libs import Interval, Period, algos, lib
  from pandas._libs.tslibs import conversion
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.base import _registry
  from pandas.core.dtypes.dtypes import CategoricalDtype, DatetimeTZDtype, ExtensionDtype, IntervalDtype, PeriodDtype, SparseDtype
  from pandas.core.dtypes.generic import ABCIndex
  from pandas.core.dtypes.inference import is_array_like, is_bool, is_complex, is_dataclass, is_decimal, is_dict_like, is_file_like, is_float, is_hashable, is_integer, is_interval, is_iterator, is_list_like, is_named_tuple, is_nested_list_like, is_number, is_re, is_re_compilable, is_scalar, is_sequence
label_desc: Use image node_id 2 for calling a global function with example usage: ensure_python_int(value) and returns: new_value