code: def get_sample_weight_array(y_train):
      y_train = copy.deepcopy(y_train)
      if isinstance(y_train, np.ndarray):
          y_train = pd.Series(y_train)
      elif isinstance(y_train, pd.Series):
          pass
      elif isinstance(y_train, pd.DataFrame):
          ### if it is a dataframe, return only if it s one column dataframe ##
          y_train = y_train.iloc[:, 0]
      else:
          ### if you cannot detect the type or if it is a multi-column dataframe, ignore it
          return None
      classes = np.unique(y_train)
      class_weights = compute_class_weight(
          "balanced", classes=classes, y=y_train
      )
      if len(class_weights[(class_weights < 1)]) > 0:
          ### if the weights are less than 1, then divide them until the lowest weight is 1.
          class_weights = class_weights / min(class_weights)
      else:
          class_weights = class_weights
      ### even after you change weights if they are all below 1.5 do this ##
      # if (class_weights<=1.5).all():
      #    class_weights = np.around(class_weights+0.49)
      class_weights = class_weights.astype(int)
      wt = dict(zip(classes, class_weights))
  
      ### Map class weights to corresponding target class values
      ### You have to make sure class labels have range (0, n_classes-1)
      wt_array = y_train.map(wt)
      # set(zip(y_train, wt_array))
  
      # Convert wt series to wt array
      wt_array = wt_array.values
      return wt_array
  
imports: import pandas
  import numpy
  from sklearn.model_selection import train_test_split
  from sklearn.model_selection import KFold
  from sklearn.model_selection import GridSearchCV
  from sklearn.multioutput import MultiOutputClassifier, MultiOutputRegressor
  from sklearn.multiclass import OneVsRestClassifier
  import xgboost
  from xgboost.sklearn import XGBClassifier
  from xgboost.sklearn import XGBRegressor
  from sklearn.model_selection import train_test_split
  from sklearn.multiclass import OneVsRestClassifier
  from sklearn.preprocessing import LabelEncoder
  import lightgbm
  from sklearn.model_selection import KFold, cross_val_score, StratifiedKFold
  import seaborn
  from sklearn.preprocessing import OneHotEncoder, LabelEncoder, label_binarize
  import csv
  import re
  from xgboost import XGBRegressor, XGBClassifier
  from sklearn.metrics import mean_squared_log_error, mean_squared_error, balanced_accuracy_score
  from scipy import stats
  from sklearn.model_selection import RandomizedSearchCV
  import scipy
  import time
  import copy
  from sklearn.preprocessing import StandardScaler, MinMaxScaler
  from collections import Counter, defaultdict
  import pdb
  import time
  from sklearn.preprocessing import StandardScaler, MinMaxScaler
  from sklearn.impute import SimpleImputer
  from sklearn.preprocessing import OneHotEncoder
  from sklearn.feature_extraction.text import CountVectorizer
  from sklearn.linear_model import LogisticRegression
  from sklearn.compose import make_column_transformer
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import LabelEncoder, LabelBinarizer
  from sklearn.base import BaseEstimator, TransformerMixin
  import pdb
  from sklearn.base import TransformerMixin
  from collections import defaultdict
  from sklearn.preprocessing import MaxAbsScaler
  from sklearn.preprocessing import FunctionTransformer
  from ..utils import My_LabelEncoder, My_LabelEncoder_Pipe
  from ..utils import left_subtract
  import xgboost
  from sklearn.utils.class_weight import compute_class_weight
  import copy
  from collections import Counter
  from collections import OrderedDict
  from collections import defaultdict
  from collections import OrderedDict
  from sklearn.impute import SimpleImputer
label_desc: Use image node_id 4 for calling a global function with example usage: get_sample_weight_array(y_train) and returns: wt_array, None