code: def test_infer_schema_on_objects_and_arrays_to_and_from_dict():
      data = [
          {
              "messages": [
                  {
                      "role": "system",
                      "content": "Translate every message you receive to French.",
                  },
                  {
                      "role": "user",
                      "content": "I like machine learning",
                  },
              ],
          },
          {
              "messages": [
                  {
                      "role": "user",
                      "content": "Summarize the following document ...",
                      "name": "jeff",
                  },
              ]
          },
      ]
      schema = _infer_schema(data)
      assert schema == Schema(
          [
              ColSpec(
                  Array(
                      Object(
                          [
                              Property("role", DataType.string),
                              Property("content", DataType.string),
                              Property(
                                  "name",
                                  DataType.string,
                                  required=False,
                              ),
                          ]
                      )
                  ),
                  name="messages",
              )
          ]
      )
      assert schema.to_dict() == [
          {
              "type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "content": {"type": "string", "required": True},
                      "name": {"type": "string", "required": False},
                      "role": {"type": "string", "required": True},
                  },
              },
              "name": "messages",
              "required": True,
          }
      ]
      assert Schema.from_json(json.dumps(schema.to_dict())) == schema
  
      data = [
          {
              "messages": [
                  {
                      "role": "system",
                      "content": "Translate every message you receive to French.",
                  },
                  {
                      "role": "user",
                      "content": "I like machine learning",
                  },
              ],
              "another_message": "hello world",
          },
          {
              "messages": [
                  {
                      "role": "user",
                      "content": "Summarize the following document ...",
                      "name": "jeff",
                  },
              ]
          },
      ]
      schema = _infer_schema(data)
      assert schema == Schema(
          [
              ColSpec(
                  Array(
                      Object(
                          [
                              Property("role", DataType.string),
                              Property("content", DataType.string),
                              Property(
                                  "name",
                                  DataType.string,
                                  required=False,
                              ),
                          ]
                      )
                  ),
                  name="messages",
              ),
              ColSpec(
                  DataType.string,
                  name="another_message",
                  required=False,
              ),
          ]
      )
      assert schema.to_dict() == [
          {
              "type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "content": {"type": "string", "required": True},
                      "name": {"type": "string", "required": False},
                      "role": {"type": "string", "required": True},
                  },
              },
              "name": "messages",
              "required": True,
          },
          {
              "type": "string",
              "name": "another_message",
              "required": False,
          },
      ]
      assert Schema.from_json(json.dumps(schema.to_dict())) == schema
  
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 45 for calling a global function with example usage: test_infer_schema_on_objects_and_arrays_to_and_from_dict() without return types