<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_serializable(self, use_bytes=False, bias_dtype=np.float32, bytes_type=bytes):
 """Convert the binary quadratic model to a serializable object. Args: use_bytes (bool, optional, default=False):
 If True, a compact representation representing the biases as bytes is used. bias_dtype (numpy.dtype, optional, default=numpy.float32):
 If `use_bytes` is True, this numpy dtype will be used to represent the bias values in the serialized format. bytes_type (class, optional, default=bytes):
 This class will be used to wrap the bytes objects in the serialization if `use_bytes` is true. Useful for when using Python 2 and using BSON encoding, which will not accept the raw `bytes` type, so `bson.Binary` can be used instead. Returns: dict: An object that can be serialized. Examples: Encode using JSON Encode using BSON_ in python 3.5+ Encode using BSON in python 2.7. Because :class:`bytes` is an alias for :class:`str`, we need to signal to the encoder that it should encode the biases and labels as binary data. See also: :meth:`~.BinaryQuadraticModel.from_serializable` :func:`json.dumps`, :func:`json.dump` JSON encoding functions :meth:`bson.BSON.encode` BSON encoding method .. _BSON: http://bsonspec.org/ """

        from dimod.package_info import __version__
        schema_version = "2.0.0"

        try:
            variables = sorted(self.variables)
        except TypeError:
            # sorting unlike types in py3
            variables = list(self.variables)

        num_variables = len(variables)

        # when doing byte encoding we can use less space depending on the
        # total number of variables
        index_dtype = np.uint16 if num_variables <= 2**16 else np.uint32

        ldata, (irow, icol, qdata), offset = self.to_numpy_vectors(
            dtype=bias_dtype,
            index_dtype=index_dtype,
            sort_indices=True,
            variable_order=variables)

        doc = {"basetype": "BinaryQuadraticModel",
               "type": type(self).__name__,
               "version": {"dimod": __version__,
                           "bqm_schema": schema_version},
               "variable_labels": variables,
               "variable_type": self.vartype.name,
               "info": self.info,
               "offset": float(offset),
               "use_bytes": bool(use_bytes)
               }

        if use_bytes:
            doc.update({'linear_biases': array2bytes(ldata, bytes_type=bytes_type),
                        'quadratic_biases': array2bytes(qdata, bytes_type=bytes_type),
                        'quadratic_head': array2bytes(irow, bytes_type=bytes_type),
                        'quadratic_tail': array2bytes(icol, bytes_type=bytes_type)})
        else:
            doc.update({'linear_biases': ldata.tolist(),
                        'quadratic_biases': qdata.tolist(),
                        'quadratic_head': irow.tolist(),
                        'quadratic_tail': icol.tolist()})

        return doc