def get_num_moving_objects(scenario, object_type=None):
        """Return the number of moving 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 moving objects.
        """
        SD = ScenarioDescription
        metadata = scenario[SD.METADATA]
        if SD.SUMMARY.NUM_MOVING_OBJECTS not in metadata[SD.SUMMARY.NUMBER_SUMMARY]:
            num_summary = SD._calculate_num_moving_objects(scenario)
        else:
            num_summary = metadata[SD.SUMMARY.NUMBER_SUMMARY]

        if object_type is None:
            return num_summary[SD.SUMMARY.NUM_MOVING_OBJECTS]
        else:
            return num_summary[SD.SUMMARY.NUM_MOVING_OBJECTS_EACH_TYPE].get(object_type, 0)
Return the number of moving 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 moving objects.
        
metadrive/scenario/scenario_description.py