code: def as_int(x, check=True):
      """Return python integer representation of number
  
      This is useful because the numpy int(val) mechanism is broken for large
      values in np.longdouble.
  
      It is also useful to work around a numpy 1.4.1 bug in conversion of uints
      to python ints.
  
      Parameters
      ----------
      x : object
          integer, unsigned integer or floating point value
      check : {True, False}
          If True, raise error for values that are not integers
  
      Returns
      -------
      i : int
          Python integer
  
      Examples
      --------
      >>> as_int(2.0)
      2
      >>> as_int(-2.0)
      -2
      >>> as_int(2.1) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
          ...
      FloatingError: Not an integer: 2.1
      >>> as_int(2.1, check=False)
      2
      """
      ix = int(x)
      if check and ix != x:
          raise FloatingError(f"Not an integer: {x}")
      return ix
  
imports: from __future__ import annotations
  import warnings
  from platform import machine, processor
  import numpy
  from .deprecated import deprecate_with_version
label_desc: Use image node_id 7 for calling a global function with example usage: as_int(x, check) and returns: ix