code: def test_infer_schema(self):
      rdd = self.sc.parallelize(
          [("dense", self.dm1), ("sparse", self.sm1)]
      )
      df = rdd.toDF()
      schema = df.schema
      self.assertTrue(schema.fields[1].dataType, self.udt)
      matrices = df.rdd.map(lambda x: x._2).collect()
      self.assertEqual(len(matrices), 2)
      for m in matrices:
          if isinstance(m, DenseMatrix):
              self.assertTrue(m, self.dm1)
          elif isinstance(m, SparseMatrix):
              self.assertTrue(m, self.sm1)
          else:
              raise ValueError(
                  "Expected a matrix but got type %r" % type(m)
              )
  
imports: import unittest
  import array
  from numpy import arange, array, array_equal, inf, ones, tile, zeros
  from pyspark.serializers import CPickleSerializer
  from pyspark.ml.linalg import DenseMatrix, DenseVector, MatrixUDT, SparseMatrix, SparseVector, Vector, VectorUDT, Vectors
  from pyspark.testing.mllibutils import MLlibTestCase
  from pyspark.sql import Row
  from pyspark.sql.functions import unwrap_udt
label_desc: Use image node_id 3 for calling the MatrixUDTTests obj's underlying member method code with example usage: obj.test_infer_schema() without return types