code: def validate_basic(params, length, allow_infnan=False, title=None):
      """
      Validate parameter vector for basic correctness.
  
      Parameters
      ----------
      params : array_like
          Array of parameters to validate.
      length : int
          Expected length of the parameter vector.
      allow_infnan : bool, optional
              Whether or not to allow `params` to contain -np.inf, np.inf, and
              np.nan. Default is False.
      title : str, optional
          Description of the parameters (e.g. "autoregressive") to use in error
          messages.
  
      Returns
      -------
      params : ndarray
          Array of validated parameters.
  
      Notes
      -----
      Basic check that the parameters are numeric and that they are the right
      shape. Optionally checks for NaN / infinite values.
      """
      title = "" if title is None else " for %s" % title
  
      # Check for invalid type and coerce to non-integer
      try:
          params = np.array(params, dtype=object)
          is_complex = [isinstance(p, complex) for p in params.ravel()]
          dtype = complex if any(is_complex) else float
          params = np.array(params, dtype=dtype)
      except TypeError:
          raise ValueError(
              "Parameters vector%s includes invalid values." % title
          )
  
      # Check for NaN, inf
      if not allow_infnan and (
          np.any(np.isnan(params)) or np.any(np.isinf(params))
      ):
          raise ValueError(
              "Parameters vector%s includes NaN or Inf values." % title
          )
  
      params = np.atleast_1d(np.squeeze(params))
  
      # Check for right number of parameters
      if params.shape != (length,):
          plural = "" if length == 1 else "s"
          raise ValueError(
              "Specification%s implies %d parameter%s, but"
              " values with shape %s were provided."
              % (title, length, plural, params.shape)
          )
  
      return params
  
label_desc: Use image node_id 2 for calling a global function with example usage: validate_basic(params, length, allow_infnan, title) and returns: params