code: def test_dataframe_from_json():
      source = pd.DataFrame(
          {
              "boolean": [True, False, True],
              "string": ["a", "b", "c"],
              "float": np.array([1.2, 2.3, 3.4], dtype=np.float32),
              "double": np.array([1.2, 2.3, 3.4], dtype=np.float64),
              "integer": np.array([3, 4, 5], dtype=np.int32),
              "long": np.array([3, 4, 5], dtype=np.int64),
              "binary": [bytes([1, 2, 3]), bytes([4, 5]), bytes([6])],
              "date_string": ["2018-02-03", "1996-03-02", "2021-03-05"],
          },
          columns=[
              "boolean",
              "string",
              "float",
              "double",
              "integer",
              "long",
              "binary",
              "date_string",
          ],
      )
  
      jsonable_df = pd.DataFrame(source, copy=True)
      jsonable_df["binary"] = jsonable_df["binary"].map(
          base64.b64encode
      )
      schema = Schema(
          [
              ColSpec("boolean", "boolean"),
              ColSpec("string", "string"),
              ColSpec("float", "float"),
              ColSpec("double", "double"),
              ColSpec("integer", "integer"),
              ColSpec("long", "long"),
              ColSpec("binary", "binary"),
              ColSpec("string", "date_string"),
          ]
      )
      parsed = dataframe_from_raw_json(
          jsonable_df.to_json(orient="split"),
          pandas_orient="split",
          schema=schema,
      )
      pd.testing.assert_frame_equal(parsed, source)
      parsed = dataframe_from_raw_json(
          jsonable_df.to_json(orient="records"),
          pandas_orient="records",
          schema=schema,
      )
      pd.testing.assert_frame_equal(parsed, source)
      # try parsing with tensor schema
      tensor_schema = Schema(
          [
              TensorSpec(np.dtype("bool"), [-1], "boolean"),
              TensorSpec(np.dtype("str"), [-1], "string"),
              TensorSpec(np.dtype("float32"), [-1], "float"),
              TensorSpec(np.dtype("float64"), [-1], "double"),
              TensorSpec(np.dtype("int32"), [-1], "integer"),
              TensorSpec(np.dtype("int64"), [-1], "long"),
              TensorSpec(np.dtype(bytes), [-1], "binary"),
          ]
      )
      parsed = dataframe_from_raw_json(
          jsonable_df.to_json(orient="split"),
          pandas_orient="split",
          schema=tensor_schema,
      )
  
      # NB: tensor schema does not automatically decode base64 encoded bytes.
      pd.testing.assert_frame_equal(parsed, jsonable_df)
      parsed = dataframe_from_raw_json(
          jsonable_df.to_json(orient="records"),
          pandas_orient="records",
          schema=tensor_schema,
      )
  
      # NB: tensor schema does not automatically decode base64 encoded bytes.
      pd.testing.assert_frame_equal(parsed, jsonable_df)
  
      # Test parse with TensorSchema with a single tensor
      tensor_schema = Schema([TensorSpec(np.dtype("float32"), [-1, 3])])
      source = pd.DataFrame(
          {
              "a": np.array([1, 2, 3], dtype=np.float32),
              "b": np.array([4.1, 5.2, 6.3], dtype=np.float32),
              "c": np.array([7, 8, 9], dtype=np.float32),
          },
          columns=["a", "b", "c"],
      )
      pd.testing.assert_frame_equal(
          source,
          dataframe_from_raw_json(
              source.to_json(orient="split"),
              pandas_orient="split",
              schema=tensor_schema,
          ),
      )
      pd.testing.assert_frame_equal(
          source,
          dataframe_from_raw_json(
              source.to_json(orient="records"),
              pandas_orient="records",
              schema=tensor_schema,
          ),
      )
  
      schema = Schema([ColSpec("datetime", "datetime")])
      parsed = dataframe_from_raw_json(
          """
  [
      {"datetime": "2022-01-01T00:00:00"},
      {"datetime": "2022-01-02T03:04:05"}
  ]
      """,
          pandas_orient="records",
          schema=schema,
      )
      expected = pd.DataFrame(
          {
              "datetime": [
                  pd.Timestamp("2022-01-01T00:00:00"),
                  pd.Timestamp("2022-01-02T03:04:05"),
              ]
          },
      )
      pd.testing.assert_frame_equal(parsed, expected)
  
imports: import base64
  import datetime
  import json
  import numpy
  import pandas
  import pytest
  from google.protobuf.text_format import Parse
  from mlflow.entities import Experiment, Metric
  from mlflow.entities.model_registry import ModelVersion, RegisteredModel
  from mlflow.exceptions import MlflowException
  from mlflow.protos.model_registry_pb2 import RegisteredModel
  from mlflow.protos.service_pb2 import Experiment
  from mlflow.protos.service_pb2 import Metric
  from mlflow.types import ColSpec, DataType, Schema, TensorSpec
  from mlflow.types.schema import Array, Object, Property
  from mlflow.types.utils import _infer_schema
  from mlflow.utils.proto_json_utils import MlflowFailedTypeConversion, _CustomJsonEncoder, _stringify_all_experiment_ids, cast_df_types_according_to_schema, dataframe_from_parsed_json, dataframe_from_raw_json, message_to_json, parse_dict, parse_tf_serving_input
  from tests.protos.test_message_pb2 import TestMessage
label_desc: Use image node_id 11 for calling a global function with example usage: test_dataframe_from_json() without return types