src/transformers/trainer_utils.py
def speed_metrics(split, start_time, num_samples=None):
    """
    Measure and return speed performance metrics.

    This function requires a time snapshot `start_time` before the operation to be measured starts and this function
    should be run immediately after the operation to be measured has completed.

    Args:

    - split: name to prefix metric (like train, eval, test...)
    - start_time: operation start time
    - num_samples: number of samples processed
    """
    runtime = time.time() - start_time
    result = {f"{split}_runtime": round(runtime, 4)}
    if num_samples is not None:
        samples_per_second = 1 / (runtime / num_samples)
        result[f"{split}_samples_per_second"] = round(samples_per_second, 3)
    return result

    Measure and return speed performance metrics.

    This function requires a time snapshot `start_time` before the operation to be measured starts and this function
    should be run immediately after the operation to be measured has completed.

    Args:

    - split: name to prefix metric (like train, eval, test...)
    - start_time: operation start time
    - num_samples: number of samples processed
    
Measure and return speed performance metrics.
This function requires a time snapshot `start_time` before the operation to be measured starts and this function
should be run immediately after the operation to be measured has completed.



name to prefix metric (like train, eval, test...)
start_time: operation start time
num_samples: number of samples processed
Measure and return speed performance metrics . This function requires a time snapshot ` start_time ` before the operation to be measured starts and this function should be run immediately after the operation to be measured has completed . name to prefix metric ( like train eval test ... ) start_time : operation start time num_samples : number of samples processed
def speed_metrics(split, start_time, num_samples=None):
    runtime = time.time() - start_time
    result = {f"{split}_runtime": round(runtime, 4)}
    if num_samples is not None:
        samples_per_second = 1 / (runtime / num_samples)
        result[f"{split}_samples_per_second"] = round(samples_per_second, 3)
    return result
def speed_metrics ( split , start_time , num_samples = None ) : runtime = time . time ( ) - start_time result = { f"{split}_runtime" : round ( runtime , 4 ) } if num_samples is not None : samples_per_second = 1 / ( runtime / num_samples ) result [ f"{split}_samples_per_second" ] = round ( samples_per_second , 3 ) return result
Measure and return speed performance metrics.
Measure and return speed performance metrics .
"""
    Measure and return speed performance metrics.

    This function requires a time snapshot `start_time` before the operation to be measured starts and this function
    should be run immediately after the operation to be measured has completed.

    Args:

    - split: name to prefix metric (like train, eval, test...)
    - start_time: operation start time
    - num_samples: number of samples processed
    """
split
start_time
num_samples