code: def convert_input_vector(y, index):
      """
      Unite target data type into a Series.
      If the target is a Series or a DataFrame, we preserve its index.
      But if the target does not contain index attribute, we use the index from the argument.
      """
      if y is None:
          raise ValueError(
              "Supervised encoders need a target for the fitting. The target cannot be None"
          )
      if isinstance(y, pd.Series):
          return y
      elif isinstance(y, np.ndarray):
          if len(np.shape(y)) == 1:  # vector
              return pd.Series(y, name="target", index=index)
          elif (
              len(np.shape(y)) == 2 and np.shape(y)[0] == 1
          ):  # single row in a matrix
              return pd.Series(y[0, :], name="target", index=index)
          elif (
              len(np.shape(y)) == 2 and np.shape(y)[1] == 1
          ):  # single column in a matrix
              return pd.Series(y[:, 0], name="target", index=index)
          else:
              raise ValueError(f"Unexpected input shape: {np.shape(y)}")
      elif np.isscalar(y):
          return pd.Series([y], name="target", index=index)
      elif isinstance(y, list):
          if len(y) == 0:  # empty list
              return pd.Series(
                  y, name="target", index=index, dtype=float
              )
          elif len(y) > 0 and not isinstance(y[0], list):  # vector
              return pd.Series(y, name="target", index=index)
          elif (
              len(y) > 0 and isinstance(y[0], list) and len(y[0]) == 1
          ):  # single row in a matrix
              flatten = lambda y: [
                  item for sublist in y for item in sublist
              ]
              return pd.Series(flatten(y), name="target", index=index)
          elif (
              len(y) == 1 and len(y[0]) == 0 and isinstance(y[0], list)
          ):  # single empty column in a matrix
              return pd.Series(
                  y[0], name="target", index=index, dtype=float
              )
          elif len(y) == 1 and isinstance(
              y[0], list
          ):  # single column in a matrix
              return pd.Series(
                  y[0], name="target", index=index, dtype=type(y[0][0])
              )
          else:
              raise ValueError("Unexpected input shape")
      elif isinstance(y, pd.DataFrame):
          if len(list(y)) == 0:  # empty DataFrame
              return pd.Series(name="target", index=index, dtype=float)
          if len(list(y)) == 1:  # a single column
              return y.iloc[:, 0]
          else:
              raise ValueError(f"Unexpected input shape: {y.shape}")
      else:
          return pd.Series(y, name="target", index=index)
  
imports: from abc import abstractmethod
  from enum import Enum, auto
  import warnings
  import pandas
  import numpy
  import sklearn.base
  from pandas.api.types import is_object_dtype, is_string_dtype, is_numeric_dtype
  from pandas.core.dtypes.dtypes import CategoricalDtype
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.exceptions import NotFittedError
  from typing import Dict, List, Optional, Union
  from scipy.sparse import csr_matrix
  from sklearn.preprocessing import LabelEncoder
label_desc: Use image node_id 6 for calling a global function with example usage: convert_input_vector(y, index) and returns: y, pd, pd, pd, pd, pd, pd, pd, pd, y, pd, pd, pd