code: def _reshape_and_cast_pandas_column_values(
      name, pd_series, tensor_spec
  ):
      if tensor_spec.shape[0] != -1 or -1 in tensor_spec.shape[1:]:
          raise MlflowException(
              "For pandas dataframe input, the first dimension of shape must be a variable "
              "dimension and other dimensions must be fixed, but in model signature the shape "
              f"of {'input ' + name if name else 'the unnamed input'} is {tensor_spec.shape}."
          )
  
      if np.isscalar(pd_series[0]):
          for shape in [(-1,), (-1, 1)]:
              if tensor_spec.shape == shape:
                  return _enforce_tensor_spec(
                      np.array(
                          pd_series, dtype=tensor_spec.type
                      ).reshape(shape),
                      tensor_spec,
                  )
          raise MlflowException(
              f"The input pandas dataframe column '{name}' contains scalar "
              "values, which requires the shape to be (-1,) or (-1, 1), but got tensor spec "
              f"shape of {tensor_spec.shape}.",
              error_code=INVALID_PARAMETER_VALUE,
          )
      elif isinstance(pd_series[0], list) and np.isscalar(
          pd_series[0][0]
      ):
          # If the pandas column contains list type values,
          # in this case, the shape and type information is lost,
          # so do not enforce the shape and type, instead,
          # reshape the array value list to the required shape, and cast value type to
          # required type.
          reshape_err_msg = (
              f"The value in the Input DataFrame column '{name}' could not be converted to the "
              f"expected shape of: '{tensor_spec.shape}'. Ensure that each of the input list "
              "elements are of uniform length and that the data can be coerced to the tensor "
              f"type '{tensor_spec.type}'"
          )
          try:
              flattened_numpy_arr = np.vstack(pd_series.tolist())
              reshaped_numpy_arr = flattened_numpy_arr.reshape(
                  tensor_spec.shape
              ).astype(tensor_spec.type)
          except ValueError:
              raise MlflowException(
                  reshape_err_msg, error_code=INVALID_PARAMETER_VALUE
              )
          if len(reshaped_numpy_arr) != len(pd_series):
              raise MlflowException(
                  reshape_err_msg, error_code=INVALID_PARAMETER_VALUE
              )
          return reshaped_numpy_arr
      elif isinstance(pd_series[0], np.ndarray):
          reshape_err_msg = (
              f"The value in the Input DataFrame column '{name}' could not be converted to the "
              f"expected shape of: '{tensor_spec.shape}'. Ensure that each of the input numpy "
              "array elements are of uniform length and can be reshaped to above expected shape."
          )
          try:
              # Because numpy array includes precise type information, so we don't convert type
              # here, so that in following schema validation we can have strict type check on
              # numpy array column.
              reshaped_numpy_arr = np.vstack(
                  pd_series.tolist()
              ).reshape(tensor_spec.shape)
          except ValueError:
              raise MlflowException(
                  reshape_err_msg, error_code=INVALID_PARAMETER_VALUE
              )
          if len(reshaped_numpy_arr) != len(pd_series):
              raise MlflowException(
                  reshape_err_msg, error_code=INVALID_PARAMETER_VALUE
              )
          return reshaped_numpy_arr
      else:
          raise MlflowException(
              "Because the model signature requires tensor spec input, the input "
              "pandas dataframe values should be either scalar value, python list "
              "containing scalar values or numpy array containing scalar values, "
              "other types are not supported.",
              error_code=INVALID_PARAMETER_VALUE,
          )
  
imports: import datetime
  import decimal
  import json
  import logging
  import os
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
  from mlflow.models import Model
  from mlflow.store.artifact.utils.models import get_model_name_and_version
  from mlflow.types import DataType, ParamSchema, ParamSpec, Schema, TensorSpec
  from mlflow.types.schema import Array, Object, Property
  from mlflow.types.utils import TensorsNotSupportedException, _infer_param_schema, clean_tensor_type
  from mlflow.utils.annotations import experimental
  from mlflow.utils.proto_json_utils import NumpyEncoder, dataframe_from_parsed_json, parse_tf_serving_input
  from mlflow.utils.uri import get_databricks_profile_uri_from_artifact_uri
label_desc: Use image node_id 13 for calling a global function with example usage: _reshape_and_cast_pandas_column_values(name, pd_series, tensor_spec) and returns: reshaped_numpy_arr, _enforce_tensor_spec, reshaped_numpy_arr