code: def get_as_dict(x):
      
      if isinstance(x, dict):
          return x
      else:
          try:
              return x._asdict()
          except AttributeError:
              return x.__dict__
docs: Return an object as a dictionary of its attributes.