code: def validate_vector_shape(name, shape, nrows, nobs):
      """
      Validate the shape of a possibly time-varying vector, or raise an exception
  
      Parameters
      ----------
      name : str
          The name of the vector being validated (used in exception messages)
      shape : array_like
          The shape of the vector to be validated. May be of size 1 or (if
          the vector is time-varying) 2.
      nrows : int
          The expected number of rows (elements of the vector).
      nobs : int
          The number of observations (used to validate the last dimension of a
          time-varying vector)
  
      Raises
      ------
      ValueError
          If the vector is not of the desired shape.
      """
      ndim = len(shape)
      # Enforce dimension
      if ndim not in [1, 2]:
          raise ValueError(
              "Invalid value for %s vector. Requires a"
              " 1- or 2-dimensional array, got %d dimensions"
              % (name, ndim)
          )
      # Enforce the shape of the vector
      if not shape[0] == nrows:
          raise ValueError(
              "Invalid dimensions for %s vector: requires %d"
              " rows, got %d" % (name, nrows, shape[0])
          )
  
      # If we do not yet know `nobs`, do not allow time-varying arrays
      if nobs is None and not (ndim == 1 or shape[-1] == 1):
          raise ValueError(
              "Invalid dimensions for %s vector: time-varying"
              " vectors cannot be given unless `nobs` is specified"
              " (implicitly when a dataset is bound or else set"
              " explicity)" % name
          )
  
      # Enforce time-varying array size
      if ndim == 2 and not shape[1] in [1, nobs]:
          raise ValueError(
              "Invalid dimensions for time-varying %s"
              " vector. Requires shape (*,%d), got %s"
              % (name, nobs, str(shape))
          )
  
imports: import numpy
  from scipy.linalg import solve_sylvester
  import pandas
  from statsmodels.compat.pandas import Appender
  from statsmodels.tools.data import _is_using_pandas
  from scipy.linalg.blas import find_best_blas_type
  from .None import _initialization, _representation, _kalman_filter, _kalman_smoother, _simulation_smoother, _cfa_simulation_smoother, _tools
label_desc: Use image node_id 21 for calling a global function with example usage: validate_vector_shape(name, shape, nrows, nobs) without return types