code: def _get_sample_weight(self, X, y, sample_weight):
      n_samples = X.shape[0]
      dtype = X.dtype
      if n_samples == 1:
          raise ValueError("n_samples=1")
  
      sample_weight = np.asarray(
          [] if sample_weight is None else sample_weight,
          dtype=np.float64,
      )
  
      sample_weight_count = sample_weight.shape[0]
      if sample_weight_count != 0 and sample_weight_count != n_samples:
          raise ValueError(
              "sample_weight and X have incompatible shapes: "
              "%r vs %r\n"
              "Note: Sparse matrices cannot be indexed w/"
              "boolean masks (use `indices=True` in CV)."
              % (len(sample_weight), X.shape)
          )
  
      ww = None
      if sample_weight_count == 0 and self.class_weight_ is None:
          return ww
  
      if sample_weight_count == 0:
          sample_weight = np.ones(n_samples, dtype=dtype)
      elif isinstance(sample_weight, Number):
          sample_weight = np.full(n_samples, sample_weight, dtype=dtype)
      else:
          sample_weight = _check_array(
              sample_weight,
              accept_sparse=False,
              ensure_2d=False,
              dtype=dtype,
              order="C",
          )
          if sample_weight.ndim != 1:
              raise ValueError(
                  "Sample weights must be 1D array or scalar"
              )
  
          if sample_weight.shape != (n_samples,):
              raise ValueError(
                  "sample_weight.shape == {}, expected {}!".format(
                      sample_weight.shape, (n_samples,)
                  )
              )
  
      if self.svm_type == SVMtype.nu_svc:
          weight_per_class = [
              np.sum(sample_weight[y == class_label])
              for class_label in np.unique(y)
          ]
  
          for i in range(len(weight_per_class)):
              for j in range(i + 1, len(weight_per_class)):
                  if self.nu * (
                      weight_per_class[i] + weight_per_class[j]
                  ) / 2 > min(weight_per_class[i], weight_per_class[j]):
                      raise ValueError("specified nu is infeasible")
  
      if np.all(sample_weight <= 0):
          if self.svm_type == SVMtype.nu_svc:
              err_msg = "negative dimensions are not allowed"
          else:
              err_msg = "Invalid input - all samples have zero or negative weights."
          raise ValueError(err_msg)
      if np.any(sample_weight <= 0):
          if self.svm_type == SVMtype.c_svc and len(
              np.unique(y[sample_weight > 0])
          ) != len(self.classes_):
              raise ValueError(
                  "Invalid input - all samples with positive weights "
                  "belong to the same class"
                  if sklearn_check_version("1.2")
                  else "Invalid input - all samples with positive weights "
                  "have the same label."
              )
      ww = sample_weight
      if self.class_weight_ is not None:
          for i, v in enumerate(self.class_weight_):
              ww[y == i] *= v
  
      if not ww.flags.c_contiguous and not ww.flags.f_contiguous:
          ww = np.ascontiguousarray(ww, dtype)
  
      return ww
  
imports: from abc import ABCMeta, abstractmethod
  from enum import Enum
  from numbers import Number, Real
  import numpy
  from scipy import sparse
  from sklearn.base import BaseEstimator
  from daal4py.sklearn._utils import sklearn_check_version
  from onedal import _backend
  from ..common._estimator_checks import _check_is_fitted
  from ..common._mixin import ClassifierMixin, RegressorMixin
  from ..common._policy import _get_policy
  from ..datatypes import from_table, to_table
  from ..utils import _check_array, _check_n_features, _check_X_y, _column_or_1d, _validate_targets
label_desc: Use image node_id 4 for calling the BaseSVM obj's underlying member method code with example usage: obj._get_sample_weight(X, y, sample_weight) and returns: ww, ww