                  try:
                      parsed = parse_datetime(value)
                      if parsed is not None:
                          return self.enforce_timezone(parsed)
                  except (ValueError, TypeError):
                      pass
              else:
                  try:
                      parsed = self.datetime_parser(value, input_format)
                      return self.enforce_timezone(parsed)
                  except (ValueError, TypeError):
                      pass
  
          humanized_format = humanize_datetime.datetime_formats(input_formats)
          self.fail('invalid', format=humanized_format)
  
      def to_representation(self, value):
 
</s> remove             if input_format.lower() == ISO_8601:
                try:
 </s> add             with contextlib.suppress(ValueError, TypeError):
                if input_format.lower() == ISO_8601: </s> remove                 except TypeError:
                    pass

 </s> add  </s> remove         except TypeError:  # Input is an unhashable type
            pass
 </s> add  </s> remove                 try:
 </s> add                 with contextlib.suppress(TypeError): </s> remove         try:
 </s> add         with contextlib.suppress(AttributeError, KeyError, ValueError):
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                  try:
                      parsed = parse_datetime(value)
                      if parsed is not None:
                          return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
                parsed = self.datetime_parser(value, input_format)
                return self.enforce_timezone(parsed)
  
          humanized_format = humanize_datetime.datetime_formats(input_formats)
          self.fail('invalid', format=humanized_format)
  
      def to_representation(self, value):
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
 Refactor: Replace try/except with contextlib.suppress() (#8676) 
rest_framework/fields.py