code: def test_spark_schema_inference_complex(spark):
      df = spark.createDataFrame(
          [(["arr"],)],
          schema=T.StructType(
              [T.StructField("arr", T.ArrayType(T.StringType()))]
          ),
      )
      schema = _infer_schema(df)
      assert schema == Schema([ColSpec(Array(DataType.string), "arr")])
  
      df = spark.createDataFrame(
          [({"str": "s", "str_nullable": None},)],
          schema=T.StructType(
              [
                  T.StructField(
                      "obj",
                      T.StructType(
                          [
                              T.StructField(
                                  "str", T.StringType(), nullable=False
                              ),
                              T.StructField(
                                  "str_nullable",
                                  T.StringType(),
                                  nullable=True,
                              ),
                          ]
                      ),
                  )
              ]
          ),
      )
      schema = _infer_schema(df)
      assert schema == Schema(
          [
              ColSpec(
                  Object(
                      [
                          Property(
                              "str", DataType.string, required=True
                          ),
                          Property(
                              "str_nullable",
                              DataType.string,
                              required=False,
                          ),
                      ]
                  ),
                  "obj",
              )
          ]
      )
  
      df = spark.createDataFrame(
          [([{"str": "s"}],)],
          schema=T.StructType(
              [
                  T.StructField(
                      "obj_arr",
                      T.ArrayType(
                          T.StructType(
                              [
                                  T.StructField(
                                      "str",
                                      T.StringType(),
                                      nullable=False,
                                  )
                              ]
                          )
                      ),
                  )
              ]
          ),
      )
  
      schema = _infer_schema(df)
      assert schema == Schema(
          [
              ColSpec(
                  Array(
                      Object(
                          [
                              Property(
                                  "str", DataType.string, required=True
                              )
                          ]
                      )
                  ),
                  "obj_arr",
              )
          ]
      )
  
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 25 for calling a global function with example usage: test_spark_schema_inference_complex(spark) without return types