code: def get_obj_attrs(obj):
      
      pr = {}
      if obj is not None:
          if isinstance(obj, numpy.core.records.record):
              for name in obj.dtype.names:
                  pr[name] = getattr(obj, name)
          elif hasattr(obj, '__dict__') and obj.__dict__:
              pr = obj.__dict__
          elif hasattr(obj, '__slots__'):
              for slot in obj.__slots__:
                  if hasattr(obj, slot):
                      pr[slot] = getattr(obj, slot)
          elif isinstance(obj, dict):
              pr = obj.copy()
          else:
              for name in dir(obj):
                  try:
                      value = getattr(obj, name)
                      if not name.startswith('__') and not inspect.ismethod(value):
                          pr[name] = value
                  except:
                      continue
  
      return pr
docs: Return a dictionary built from the attributes of the given object.