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