def get_experiment_durations(experiment_id: int, trial_idx: int) -> ExperimentDurations:
    experiment_metadata = experiment_json(experiment_id)
    end_time = dateutil.parser.parse(experiment_metadata['end_time'])
    start_time = dateutil.parser.parse(experiment_metadata['start_time'])
    experiment_duration = (end_time - start_time)
    training_duration = datetime.timedelta(seconds=0)
    validation_duration = datetime.timedelta(seconds=0)
    checkpoint_duration = datetime.timedelta(seconds=0)
    for step in experiment_metadata['trials'][trial_idx]['steps']:
        end_time = dateutil.parser.parse(step['end_time'])
        start_time = dateutil.parser.parse(step['start_time'])
        training_duration += (end_time - start_time)
        if (('validation' in step) and step['validation']):
            end_time = dateutil.parser.parse(step['validation']['end_time'])
            start_time = dateutil.parser.parse(step['validation']['start_time'])
            validation_duration += (end_time - start_time)
        if (('checkpoint' in step) and step['checkpoint']):
            end_time = dateutil.parser.parse(step['checkpoint']['end_time'])
            start_time = dateutil.parser.parse(step['checkpoint']['start_time'])
            checkpoint_duration += (end_time - start_time)
    return ExperimentDurations(experiment_duration, training_duration, validation_duration, checkpoint_duration)
def get_experiment_durations(experiment_id: int, trial_idx: int) -> ExperimentDurations:
    experiment_metadata = experiment_json(experiment_id)
    end_time = dateutil.parser.parse(experiment_metadata['end_time'])
    start_time = dateutil.parser.parse(experiment_metadata['start_time'])
    experiment_duration = (end_time - start_time)
    training_duration = datetime.timedelta(seconds=0)
    validation_duration = datetime.timedelta(seconds=0)
    checkpoint_duration = datetime.timedelta(seconds=0)
    for step in experiment_metadata['trials'][trial_idx]['steps']:
        end_time = dateutil.parser.parse(step['end_time'])
        start_time = dateutil.parser.parse(step['start_time'])
        training_duration += (end_time - start_time)
        if (('validation' in step) and step['validation']):
            end_time = dateutil.parser.parse(step['validation']['end_time'])
            start_time = dateutil.parser.parse(step['validation']['start_time'])
            validation_duration += (end_time - start_time)
        if (('checkpoint' in step) and step['checkpoint']):
            end_time = dateutil.parser.parse(step['checkpoint']['end_time'])
            start_time = dateutil.parser.parse(step['checkpoint']['start_time'])
            checkpoint_duration += (end_time - start_time)
    return ExperimentDurations(experiment_duration, training_duration, validation_duration, checkpoint_duration)