class_docstr: Base class for testing proto encoding ops.
class_docstr_tok: ["Base","class","for","testing","proto","encoding","ops","."]
code: def testRoundtripPacked(self, case):
      # Now try with the packed serialization.
      # We test the packed representations by loading the same test cases using
      # PackedTestValue instead of TestValue. To do this we rely on the text
      # format being the same for packed and unpacked fields, and reparse the test
      # message using the packed version of the proto.
      in_bufs = [
          # Note: float_format='.17g' is necessary to ensure preservation of
          # doubles and floats in text format.
          text_format.Parse(
              text_format.MessageToString(value, float_format=".17g"),
              test_example_pb2.PackedTestValue(),
          ).SerializeToString()
          for value in case.values
      ]
  
      # np.array silently truncates strings if you don't specify dtype=object.
      in_bufs = np.reshape(
          np.array(in_bufs, dtype=object), list(case.shapes)
      )
      return self._testRoundtrip(
          in_bufs,
          "tensorflow.contrib.proto.PackedTestValue",
          case.fields,
      )
  
file_path: tensorflow-upstream/tensorflow/python/kernel_tests/proto/encode_proto_op_test_base.py
imports: from absl.testing import parameterized
  import numpy
  from google.protobuf import text_format
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.kernel_tests.proto import proto_op_test_base
  from tensorflow.python.kernel_tests.proto import test_example_pb2
  from tensorflow.python.ops import array_ops
label_desc: Use image node_id 6 for calling the EncodeProtoOpTestBase obj's underlying member method code with example usage: obj.testRoundtripPacked(case) and returns: self