code: def test_param_spec_to_and_from_dict():
      spec = ParamSpec("str_param", DataType.string, "str_a", None)
      assert spec.to_dict() == {
          "name": "str_param",
          "type": "string",
          "default": "str_a",
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "str_array", DataType.string, ["str_a", "str_b"], (-1,)
      )
      assert spec.to_dict() == {
          "name": "str_array",
          "type": "string",
          "default": ["str_a", "str_b"],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec("int_param", DataType.integer, np.int32(1), None)
      assert spec.to_dict() == {
          "name": "int_param",
          "type": "integer",
          "default": 1,
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "int_array",
          DataType.integer,
          [np.int32(1), np.int32(2)],
          (-1,),
      )
      assert spec.to_dict() == {
          "name": "int_array",
          "type": "integer",
          "default": [1, 2],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec("bool_param", DataType.boolean, True, None)
      assert spec.to_dict() == {
          "name": "bool_param",
          "type": "boolean",
          "default": True,
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "bool_array", DataType.boolean, [True, False], (-1,)
      )
      assert spec.to_dict() == {
          "name": "bool_array",
          "type": "boolean",
          "default": [True, False],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec("double_param", DataType.double, 1.0, None)
      assert spec.to_dict() == {
          "name": "double_param",
          "type": "double",
          "default": 1.0,
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "double_array", DataType.double, [1.0, 2.0], (-1,)
      )
      assert spec.to_dict() == {
          "name": "double_array",
          "type": "double",
          "default": [1.0, 2.0],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "float_param", DataType.float, np.float32(0.1), None
      )
      assert spec.to_dict() == {
          "name": "float_param",
          "type": "float",
          "default": float(np.float32(0.1)),
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "float_array",
          DataType.float,
          [np.float32(0.1), np.float32(0.2)],
          (-1,),
      )
      assert spec.to_dict() == {
          "name": "float_array",
          "type": "float",
          "default": [float(np.float32(0.1)), float(np.float32(0.2))],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec("long_param", DataType.long, 100, None)
      assert spec.to_dict() == {
          "name": "long_param",
          "type": "long",
          "default": 100,
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec("long_array", DataType.long, [100, 200], (-1,))
      assert spec.to_dict() == {
          "name": "long_array",
          "type": "long",
          "default": [100, 200],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "datetime_param",
          DataType.datetime,
          np.datetime64("2023-06-26 00:00:00"),
          None,
      )
      assert spec.to_dict() == {
          "name": "datetime_param",
          "type": "datetime",
          "default": "2023-06-26T00:00:00",
          "shape": None,
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
      spec = ParamSpec(
          "datetime_array",
          DataType.datetime,
          [
              np.datetime64("2023-06-26 00:00:00"),
              np.datetime64("2023-06-27 00:00:00"),
          ],
          (-1,),
      )
      assert spec.to_dict() == {
          "name": "datetime_array",
          "type": "datetime",
          "default": ["2023-06-26T00:00:00", "2023-06-27T00:00:00"],
          "shape": (-1,),
      }
      assert (
          ParamSpec.from_json_dict(
              **json.loads(json.dumps(spec.to_dict()))
          )
          == spec
      )
  
imports: import datetime
  import json
  import math
  import re
  import numpy
  import pandas
  import pyspark
  import pyspark.sql.types
  import pytest
  from scipy.sparse import csc_matrix, csr_matrix
  from mlflow.exceptions import MlflowException
  from mlflow.models.utils import _enforce_tensor_spec
  from mlflow.pyfunc import _parse_spark_datatype
  from mlflow.types import DataType
  from mlflow.types.schema import Array, ColSpec, Object, ParamSchema, ParamSpec, Property, Schema, TensorSpec
  from mlflow.types.utils import _get_tensor_shape, _infer_colspec_type, _infer_param_schema, _infer_schema, _validate_input_dictionary_contains_only_strings_and_lists_of_strings
label_desc: Use image node_id 30 for calling a global function with example usage: test_param_spec_to_and_from_dict() without return types