code: def ensure1d(
      x: int | float | Sequence[int | float] | ArrayLike,  # noqa: E231
      name: Hashable | None,
      series: bool = False,
  ) -> NDArray | Series:
      if isinstance(x, Series):
          if not isinstance(x.name, str):
              x.name = str(x.name)
          if series:
              return x
          else:
              return np.asarray(x)
  
      if isinstance(x, DataFrame):
          if x.shape[1] != 1:
              raise ValueError(
                  f"{name} must be squeezable to 1 dimension"
              )
          if not series:
              return np.asarray(x.iloc[:, 0])
          x_series = Series(x.iloc[:, 0], x.index)
          if not isinstance(x_series.name, str):
              x_series.name = str(x_series.name)
          return x_series
  
      x_arr = np.squeeze(np.asarray(x))
      if x_arr.ndim == 0:
          x_arr = x_arr[None]
      elif x_arr.ndim != 1:
          raise ValueError(f"{name} must be squeezable to 1 dimension")
  
      if series:
          return Series(x_arr, name=name)
      else:
          return x_arr
  
imports: from __future__ import annotations
  from arch.compat.pandas import is_datetime64_any_dtype
  from abc import ABCMeta
  from collections.abc import Hashable, Sequence
  import datetime
  from functools import cached_property
  from typing import Any, Literal, overload
  import numpy
  from pandas import DataFrame, DatetimeIndex, Index, NaT, Series, Timestamp, to_datetime
  from arch.typing import AnyPandas, ArrayLike, DateLike, NDArray
label_desc: Use image node_id 3 for calling a global function with example usage: ensure1d(x, name, series) and returns: x_series, Series, x_arr, x, np, np