code: def ensure_removed(obj, attr):
      """
      Ensure attribute attached to 'obj' during testing is removed in the end
      """
      try:
          yield
  
      finally:
          try:
              delattr(obj, attr)
          except AttributeError:
              pass
  
imports: import contextlib
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.testing.pandasutils import assert_produces_warning, ComparisonTestBase
  from pyspark.pandas.extensions import register_dataframe_accessor, register_series_accessor, register_index_accessor
label_desc: Use image node_id 1 for calling a global function with example usage: ensure_removed(obj, attr) without return types