docs: def is_valid(bson):
      """Check that the given string represents valid :class:`BSON` data.
  
      Raises :class:`TypeError` if `bson` is not an instance of
      :class:`str` (:class:`bytes` in python 3). Returns ``True``
      if `bson` is valid :class:`BSON`, ``False`` otherwise.
  
      :Parameters:
        - `bson`: the data to be validated
      """
      if not isinstance(bson, bytes):
          raise TypeError("BSON data must be an instance of a subclass of bytes")
  
      try:
          _bson_to_dict(bson, DEFAULT_CODEC_OPTIONS)
          return True
      except Exception:
          return False