def get_num_objects(scenario, object_type: Optional[str] = None):
        """Return the number of objects (vehicles, pedestrians, cyclists, ...).

        Args:
            scenario: The input scenario.
            object_type: The string of the object type. If None, return the number of all objects.

        Returns:
            (int) The number of objects.
        """
        SD = ScenarioDescription
        metadata = scenario[SD.METADATA]
        if SD.SUMMARY.NUMBER_SUMMARY not in metadata:
            scenario[SD.METADATA][SD.SUMMARY.NUMBER_SUMMARY] = SD.get_number_summary(scenario)
        if object_type is None:
            return metadata[SD.SUMMARY.NUMBER_SUMMARY][SD.SUMMARY.NUM_OBJECTS]
        else:
            return metadata[SD.SUMMARY.NUMBER_SUMMARY][SD.SUMMARY.NUM_OBJECTS_EACH_TYPE].get(object_type, 0)
Return the number of objects (vehicles, pedestrians, cyclists, ...).

        Args:
            scenario: The input scenario.
            object_type: The string of the object type. If None, return the number of all objects.

        Returns:
            (int) The number of objects.
        
metadrive/scenario/scenario_description.py