code: def testCanonicalFrom(self):
      mask = field_mask_pb2.FieldMask()
      out_mask = field_mask_pb2.FieldMask()
      # Paths will be sorted.
      mask.FromJsonString("baz.quz,bar,foo")
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual("bar,baz.quz,foo", out_mask.ToJsonString())
      # Duplicated paths will be removed.
      mask.FromJsonString("foo,bar,foo")
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual("bar,foo", out_mask.ToJsonString())
      # Sub-paths of other paths will be removed.
      mask.FromJsonString("foo.b1,bar.b1,foo.b2,bar")
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual("bar,foo.b1,foo.b2", out_mask.ToJsonString())
  
      # Test more deeply nested cases.
      mask.FromJsonString("foo.bar.baz1,foo.bar.baz2.quz,foo.bar.baz2")
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual(
          "foo.bar.baz1,foo.bar.baz2", out_mask.ToJsonString()
      )
      mask.FromJsonString("foo.bar.baz1,foo.bar.baz2,foo.bar.baz2.quz")
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual(
          "foo.bar.baz1,foo.bar.baz2", out_mask.ToJsonString()
      )
      mask.FromJsonString(
          "foo.bar.baz1,foo.bar.baz2,foo.bar.baz2.quz,foo.bar"
      )
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual("foo.bar", out_mask.ToJsonString())
      mask.FromJsonString(
          "foo.bar.baz1,foo.bar.baz2,foo.bar.baz2.quz,foo"
      )
      out_mask.CanonicalFormFromMask(mask)
      self.assertEqual("foo", out_mask.ToJsonString())
  
imports: from datetime import datetime
  from google.protobuf import any_pb2
  from google.protobuf import duration_pb2
  from google.protobuf import field_mask_pb2
  from google.protobuf import struct_pb2
  from google.protobuf import timestamp_pb2
  from google.protobuf import unittest_pb2
  from google.protobuf.internal import any_test_pb2
  from google.protobuf.internal import test_util
  from google.protobuf.internal import well_known_types
  from google.protobuf import descriptor
  from google.protobuf import text_format
label_desc: Use image node_id 3 for calling the FieldMaskTest obj's underlying member method code with example usage: obj.testCanonicalFrom() without return types