<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def num_samples(self, sr=None):
 """ Return the number of samples. Args: sr (int):
 Calculate the number of samples with the given sampling-rate. If None use the native sampling-rate. Returns: int: Number of samples """

        native_sr = self.sampling_rate
        num_samples = units.seconds_to_sample(self.duration, native_sr)

        if sr is not None:
            ratio = float(sr) / native_sr
            num_samples = int(np.ceil(num_samples * ratio))

        return num_samples