code: def deserialize_enum(data, enum_obj):
          
          if isinstance(data, enum_obj):
              return data
          if isinstance(data, Enum):
              data = data.value
          if isinstance(data, int):
              # Workaround. We might consider remove it in the future.
              # https://github.com/Azure/azure-rest-api-specs/issues/141
              try:
                  return list(enum_obj.__members__.values())[data]
              except IndexError:
                  error = "{!r} is not a valid index for enum {!r}"
                  raise DeserializationError(error.format(data, enum_obj))
          try:
              return enum_obj(str(data))
          except ValueError:
              for enum_value in enum_obj:
                  if enum_value.value.lower() == str(data).lower():
                      return enum_value
              # We don't fail anymore for unknown value, we deserialize as a string
              _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj)
              return Deserializer.deserialize_unicode(data)
docs: Deserialize string into enum object.
  
          :param str data: response string to be deserialized.
          :param Enum enum_obj: Enum object to deserialize to.
          :rtype: Enum
          :raises: DeserializationError if string is not valid enum value.