def valid_sample(sample):
    """Check whether a sample is valid.

        sample: sample to be checked

    """
    return sample is not None and isinstance(sample, dict) and len(list(
        sample.keys())) > 0 and not sample.get('__bad__', False)
