code: def testPreservesMetadata(self):
      s = schema.Struct(
          ("a", schema.Scalar(np.float32)),
          (
              "b",
              schema.Scalar(
                  np.int32,
                  metadata=schema.Metadata(categorical_limit=5),
              ),
          ),
          (
              "c",
              schema.List(
                  schema.Scalar(
                      np.int32,
                      metadata=schema.Metadata(categorical_limit=6),
                  )
              ),
          ),
      )
      # attach metadata to lengths field
      s.c.lengths.set_metadata(schema.Metadata(categorical_limit=7))
  
      self.assertEqual(None, s.a.metadata)
      self.assertEqual(5, s.b.metadata.categorical_limit)
      self.assertEqual(6, s.c.value.metadata.categorical_limit)
      self.assertEqual(7, s.c.lengths.metadata.categorical_limit)
      sc = s.clone()
      self.assertEqual(None, sc.a.metadata)
      self.assertEqual(5, sc.b.metadata.categorical_limit)
      self.assertEqual(6, sc.c.value.metadata.categorical_limit)
      self.assertEqual(7, sc.c.lengths.metadata.categorical_limit)
      sv = schema.from_blob_list(
          s,
          [
              np.array([3.4]),
              np.array([2]),
              np.array([3]),
              np.array([1, 2, 3]),
          ],
      )
      self.assertEqual(None, sv.a.metadata)
      self.assertEqual(5, sv.b.metadata.categorical_limit)
      self.assertEqual(6, sv.c.value.metadata.categorical_limit)
      self.assertEqual(7, sv.c.lengths.metadata.categorical_limit)
  
imports: from caffe2.python import core, schema
  import numpy
  import unittest
  import pickle
  import random
label_desc: Use image node_id 12 for calling the TestDB obj's underlying member method code with example usage: obj.testPreservesMetadata() without return types