code: def _clear(msg, field_name) -> bool:
      """Clear a field if set and return True if it was."""
      try:
          if msg.HasField(field_name):
              msg.ClearField(field_name)
              return True
      except ValueError:
          if msg.__getattribute__(field_name):
              msg.ClearField(field_name)
              return True
      return False
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import traceback
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
  from absl.testing import absltest
  import apache_beam
  from apache_beam.testing import util
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow.python.util.protobuf import compare
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _clear(msg, field_name) and returns: False, True, True