code: def get_fields(schema, exclude_dump_only=False):
      
      if hasattr(schema, "fields"):
          fields = schema.fields
      elif hasattr(schema, "_declared_fields"):
          fields = copy.deepcopy(schema._declared_fields)
      else:
          raise ValueError(
              "{!r} doesn't have either `fields` or `_declared_fields`.".format(schema)
          )
      Meta = getattr(schema, "Meta", None)
      warn_if_fields_defined_in_meta(fields, Meta)
      return filter_excluded_fields(fields, Meta, exclude_dump_only)
docs: Return fields from schema
  
      :param Schema schema: A marshmallow Schema instance or a class object
      :param bool exclude_dump_only: whether to filter fields in Meta.dump_only
      :rtype: dict, of field name field object pairs