code: def testWriteEventInvalidType(self):
      class _Invalid(object):
          def __str__(self):
              return "Invalid"
  
      with self.assertRaisesRegex(TypeError, "Invalid"):
          _pywrap_events_writer.EventsWriter(b"foo").WriteEvent(
              _Invalid()
          )
  
file_path: tensorflow/tensorflow/python/client/events_writer_test.py
imports: import os.path
  from tensorflow.core.framework import summary_pb2
  from tensorflow.core.util import event_pb2
  from tensorflow.python import pywrap_tensorflow
  from tensorflow.python.client import _pywrap_events_writer
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.lib.io import tf_record
  from tensorflow.python.platform import googletest
  from tensorflow.python.util import compat
label_desc: Use image node_id 2 for calling the PywrapeventsWriterTest obj's underlying member method code with example usage: obj.testWriteEventInvalidType() and returns: str