code: def check_int(val):
      r
  
      if not isinstance(val, (int, float, list, tuple, np.ndarray)):
          raise TypeError('Invalid input type.')
      if isinstance(val, float):
          val = int(val)
      elif isinstance(val, (list, tuple)):
          val = np.array(val, dtype=int)
      elif isinstance(val, np.ndarray) and (not np.issubdtype(val.dtype,
                                                              np.integer)):
          val = val.astype(int)
  
      return val
docs: r"""Check if input value is an int or a np.ndarray of ints, if not convert.
  
      Parameters
      ----------
      val : any
          Input value
  
      Returns
      -------
      int or np.ndarray of ints
  
      Examples
      --------
      >>> from modopt.base.types import check_int
      >>> a = np.arange(5).astype(float)
      >>> a
      array([ 0.,  1.,  2.,  3.,  4.])
      >>> check_float(a)
      array([0, 1, 2, 3, 4])