code: def test_as_spark_type_pandas_on_spark_dtype(self):
      type_mapper = {
          # binary
          np.character: (np.character, BinaryType()),
          np.bytes_: (np.bytes_, BinaryType()),
          np.string_: (np.bytes_, BinaryType()),
          bytes: (np.bytes_, BinaryType()),
          # integer
          np.int8: (np.int8, ByteType()),
          np.byte: (np.int8, ByteType()),
          np.int16: (np.int16, ShortType()),
          np.int32: (np.int32, IntegerType()),
          np.int64: (np.int64, LongType()),
          int: (np.int64, LongType()),
          # floating
          np.float32: (np.float32, FloatType()),
          np.float64: (np.float64, DoubleType()),
          float: (np.float64, DoubleType()),
          # string
          np.unicode_: (np.unicode_, StringType()),
          str: (np.unicode_, StringType()),
          # bool
          bool: (np.bool_, BooleanType()),
          # datetime
          np.datetime64: (np.datetime64, TimestampType()),
          datetime.datetime: (
              np.dtype("datetime64[ns]"),
              TimestampType(),
          ),
          # DateType
          datetime.date: (np.dtype("object"), DateType()),
          # DecimalType
          decimal.Decimal: (np.dtype("object"), DecimalType(38, 18)),
          # ArrayType
          np.ndarray: (np.dtype("object"), ArrayType(StringType())),
          # CategoricalDtype
          CategoricalDtype(categories=["a", "b", "c"]): (
              CategoricalDtype(categories=["a", "b", "c"]),
              LongType(),
          ),
      }
  
      for numpy_or_python_type, (
          dtype,
          spark_type,
      ) in type_mapper.items():
          self.assertEqual(
              as_spark_type(numpy_or_python_type), spark_type
          )
          self.assertEqual(
              pandas_on_spark_type(numpy_or_python_type),
              (dtype, spark_type),
          )
  
          if isinstance(numpy_or_python_type, CategoricalDtype):
              # Nested CategoricalDtype is not yet supported.
              continue
  
          self.assertEqual(
              as_spark_type(List[numpy_or_python_type]),
              ArrayType(spark_type),
          )
          self.assertEqual(
              pandas_on_spark_type(List[numpy_or_python_type]),
              (np.dtype("object"), ArrayType(spark_type)),
          )
  
          # For NumPy typing, NumPy version should be 1.21+
          if LooseVersion(np.__version__) >= LooseVersion("1.21"):
              import numpy.typing as ntp
  
              self.assertEqual(
                  as_spark_type(ntp.NDArray[numpy_or_python_type]),
                  ArrayType(spark_type),
              )
              self.assertEqual(
                  pandas_on_spark_type(
                      ntp.NDArray[numpy_or_python_type]
                  ),
                  (np.dtype("object"), ArrayType(spark_type)),
              )
  
      with self.assertRaisesRegex(
          TypeError, "Type uint64 was not understood."
      ):
          as_spark_type(np.dtype("uint64"))
  
      with self.assertRaisesRegex(
          TypeError, "Type object was not understood."
      ):
          as_spark_type(np.dtype("object"))
  
      with self.assertRaisesRegex(
          TypeError, "Type uint64 was not understood."
      ):
          pandas_on_spark_type(np.dtype("uint64"))
  
      with self.assertRaisesRegex(
          TypeError, "Type object was not understood."
      ):
          pandas_on_spark_type(np.dtype("object"))
  
imports: import sys
  import unittest
  import datetime
  import decimal
  from typing import List
  import pandas
  import pandas
  from pandas.api.types import CategoricalDtype
  import numpy
  from pyspark.loose_version import LooseVersion
  from pyspark.sql.types import ArrayType, BinaryType, BooleanType, FloatType, IntegerType, LongType, StringType, StructField, StructType, ByteType, ShortType, DateType, DecimalType, DoubleType, TimestampType
  from pyspark.pandas.typedef import as_spark_type, extension_dtypes_available, extension_float_dtypes_available, extension_object_dtypes_available, infer_return_type, pandas_on_spark_type
  from pyspark import pandas
label_desc: Use image node_id 7 for calling the TypeHintTestsMixin obj's underlying member method code with example usage: obj.test_as_spark_type_pandas_on_spark_dtype() without return types