code: def _check_constant_params(
      a, has_const=False, use_const=True, rtol=1e-05, atol=1e-08
  ):
      
  
      if all((has_const, use_const)):
          if not _confirm_constant(a):
              raise ValueError(
                  "Data does not contain a constant; specify" " has_const=False"
              )
          k = a.shape[-1] - 1
      elif not any((has_const, use_const)):
          if _confirm_constant(a):
              raise ValueError(
                  "Data already contains a constant; specify" " has_const=True"
              )
          k = a.shape[-1]
      elif not has_const and use_const:
          # Also run a quick check to confirm that `a` is *not* ~N(0,1).
          #     In this case, constant should be zero. (exclude it entirely)
          c1 = np.allclose(a.mean(axis=0), b=0.0, rtol=rtol, atol=atol)
          c2 = np.allclose(a.std(axis=0), b=1.0, rtol=rtol, atol=atol)
          if c1 and c2:
              # TODO: maybe we want to just warn here?
              raise ValueError(
                  "Data appears to be ~N(0,1).  Specify" " use_constant=False."
              )
          # `has_constant` does checking on its own and raises VE if True
          try:
              a = add_constant(a, has_constant="raise")
          except ValueError as e:
              raise ValueError(
                  "X data already contains a constant; please specify"
                  " has_const=True"
              ) from e
          k = a.shape[-1] - 1
      else:
          raise ValueError("`use_const` == False implies has_const is False.")
  
      return k, a
docs: Helper func to interaction between has_const and use_const params.
  
      has_const   use_const   outcome
      ---------   ---------   -------
      True        True        Confirm that a has constant; return a
      False       False       Confirm that a doesn't have constant; return a
      False       True        Confirm that a doesn't have constant; add constant
      True        False       ValueError