code: def test_tensor_spec():
      a1 = TensorSpec(np.dtype("float64"), (-1, 3, 3), "a")
      a2 = TensorSpec(
          np.dtype("float"), (-1, 3, 3), "a"
      )  # float defaults to float64
      a3 = TensorSpec(np.dtype("float"), [-1, 3, 3], "a")
      a4 = TensorSpec(np.dtype("int"), (-1, 3, 3), "a")
      assert a1 == a2
      assert a1 == a3
      assert a1 != a4
      b1 = TensorSpec(np.dtype("float64"), (-1, 3, 3), "b")
      assert b1 != a1
      with pytest.raises(
          TypeError, match="Expected `type` to be instance"
      ):
          TensorSpec("Unsupported", (-1, 3, 3), "a")
      with pytest.raises(
          TypeError, match="Expected `shape` to be instance"
      ):
          TensorSpec(np.dtype("float64"), np.array([-1, 2, 3]), "b")
      with pytest.raises(
          MlflowException,
          match="MLflow does not support size information in flexible numpy data types",
      ):
          TensorSpec(np.dtype("<U10"), (-1,), "b")
  
      a5 = TensorSpec.from_json_dict(**a1.to_dict())
      assert a5 == a1
      assert (
          TensorSpec.from_json_dict(
              **json.loads(json.dumps(a1.to_dict()))
          )
          == a1
      )
      a6 = TensorSpec(np.dtype("float64"), (-1, 3, 3))
      a7 = TensorSpec(np.dtype("float64"), (-1, 3, 3), None)
      assert a6 == a7
      assert (
          TensorSpec.from_json_dict(
              **json.loads(json.dumps(a6.to_dict()))
          )
          == a6
      )
  
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 3 for calling a global function with example usage: test_tensor_spec() without return types