docs: def to_bytes(data):
      """Takes an input str or bytes object and returns an equivalent bytes object.
  
      :param data: Input data
      :type data: str or bytes
      :returns: Data normalized to bytes
      :rtype: bytes
      """
      if isinstance(data, six.string_types) and not isinstance(data, bytes):
          return codecs.encode(data, TEXT_ENCODING)
      return data