code: def polars_type_to_constructor(
      dtype: PolarsDataType,
  ) -> Callable[[str, Sequence[Any], bool], PySeries]:
      """Get the right PySeries constructor for the given Polars dtype."""
      try:
          base_type = dtype.base_type()
          # special case for Array as it needs to pass the width argument
          # upon construction
          if base_type == dt.Array:
              return functools.partial(PySeries.new_array, dtype.width, dtype.inner)  # type: ignore[union-attr]
  
          return _POLARS_TYPE_TO_CONSTRUCTOR[base_type]
      except KeyError:  # pragma: no cover
          raise ValueError(
              f"cannot construct PySeries for type {dtype!r}"
          ) from None
  
file_path: polars/py-polars/polars/datatypes/constructor.py
imports: from __future__ import annotations
  import functools
  from decimal import Decimal
  from typing import TYPE_CHECKING, Any, Callable, Sequence
  from polars import datatypes
  from polars.dependencies import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: polars_type_to_constructor(dtype) and returns: _POLARS_TYPE_TO_CONSTRUCTOR, functools