code: def check_weights(weights, data, verbose):
      if weights is None:
          # weights not specified
          # do nothing
          pass
      else:
          check_data_again(data)
  
          if isinstance(weights, pd.Series):
              weights = np.array(weights)
              verbose_cat(
                  "  -> sampling weights  :  Parameter 'weights' was a pandas.Series. Converted to a numpy.ndarray.",
                  verbose=verbose,
              )
          elif (
              isinstance(weights, np.ndarray)
              and len(weights.shape) != 1
          ):
              raise TypeError("'weights' must have only one dimension")
          elif not isinstance(weights, np.ndarray):
              raise TypeError(
                  "'weights' must be a numpy.ndarray (1d) or pandas.Series"
              )
  
          verbose_cat(
              "  -> sampling weights  : "
              + str(weights.shape[0])
              + " values",
              verbose=verbose,
          )
  
          if weights.shape[0] != data.shape[0]:
              verbose_cat(
                  "  -> sampling weights  :  Length of 'weights' is different than the number of rows in 'data'.",
                  verbose=verbose,
              )
  
      return weights
  
imports: import numpy
  import pandas
  from copy import deepcopy
  from warnings import warn
  from .helper import verbose_cat, is_y_in_data, get_model_info
  from .yhat import get_predict_function_and_model_type
label_desc: Use image node_id 6 for calling a global function with example usage: check_weights(weights, data, verbose) and returns: weights