<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_samples(self, sr=None, offset=0, duration=None):
 """ Return the samples from the track in the container. Uses librosa for resampling, if needed. Args: sr (int):
 If ``None``, uses the sampling rate given by the file, otherwise resamples to the given sampling rate. offset (float):
 The time in seconds, from where to start reading the samples (rel. to the file start). duration (float):
 The length of the samples to read in seconds. Returns: np.ndarray: A numpy array containing the samples as a floating point (numpy.float32) time series. """

        with self.container.open_if_needed(mode='r') as cnt:
            samples, native_sr = cnt.get(self.key)

            start_sample_index = int(offset * native_sr)

            if duration is None:
                end_sample_index = samples.shape[0]
            else:
                end_sample_index = int((offset + duration) * native_sr)

            samples = samples[start_sample_index:end_sample_index]

            if sr is not None and sr != native_sr:
                samples = librosa.core.resample(
                    samples,
                    native_sr,
                    sr,
                    res_type='kaiser_best'
                )

            return samples