def formats(self, formats=None):
        """Get a graph index with the specified allowed sparse format(s) or
        query for the usage status of sparse formats.

        If the graph has multiple edge types, they will have the same
        sparse format.

        When ``formats`` is not None, if the intersection between `formats` and
        the current graph's created sparse format(s) is not empty, the returned
        cloned graph only retains all sparse format(s) in the intersection. If
        the intersection is empty, a sparse format will be selected to be
        created following the order of ``'coo' -> 'csr' -> 'csc'``.

        Parameters
        ----------
        formats : str or list of str or None

            * If formats is None, return the usage status of sparse formats
            * Otherwise, it can be ``'coo'``/``'csr'``/``'csc'`` or a sublist of
            them, specifying the sparse formats to use.

        Returns
        -------
        dict or GraphIndex

            * If formats is None, the result will be a dict recording the usage
              status of sparse formats.
            * Otherwise, a GraphIndex will be returned, which is a clone of the
              original graph with the specified allowed sparse format(s)
              ``formats``.

        """
        formats_allowed = _CAPI_DGLHeteroGetAllowedFormats(self)
        formats_created = _CAPI_DGLHeteroGetCreatedFormats(self)
        created = []
        not_created = []
        if formats is None:
            for fmt in ["coo", "csr", "csc"]:
                if fmt in formats_allowed:
                    if fmt in formats_created:
                        created.append(fmt)
                    else:
                        not_created.append(fmt)
            return {"created": created, "not created": not_created}
        else:
            if isinstance(formats, str):
                formats = [formats]
            return _CAPI_DGLHeteroGetFormatGraph(self, formats)
Get a graph index with the specified allowed sparse format(s) or
        query for the usage status of sparse formats.

        If the graph has multiple edge types, they will have the same
        sparse format.

        When ``formats`` is not None, if the intersection between `formats` and
        the current graph's created sparse format(s) is not empty, the returned
        cloned graph only retains all sparse format(s) in the intersection. If
        the intersection is empty, a sparse format will be selected to be
        created following the order of ``'coo' -> 'csr' -> 'csc'``.

        Parameters
        ----------
        formats : str or list of str or None

            * If formats is None, return the usage status of sparse formats
            * Otherwise, it can be ``'coo'``/``'csr'``/``'csc'`` or a sublist of
            them, specifying the sparse formats to use.

        Returns
        -------
        dict or GraphIndex

            * If formats is None, the result will be a dict recording the usage
              status of sparse formats.
            * Otherwise, a GraphIndex will be returned, which is a clone of the
              original graph with the specified allowed sparse format(s)
              ``formats``.

        
python/dgl/heterograph_index.py