<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _visible_layers_count(self):
 """Calculate the number of visible layers in the legend. .. versionadded: 3.1 :returns: Count of layers that are actually visible. :rtype: int """

        treeroot = QgsProject.instance().layerTreeRoot()
        return len([lyr for lyr in treeroot.findLayers() if lyr.isVisible()])