code: def to_dict(self, remove_nones=False):
          
          content = {
              'uri': self.uri,
              'protocol_info': self.protocol_info,
              'import_uri': self.import_uri,
              'size': self.size,
              'duration': self.duration,
              'bitrate': self.bitrate,
              'sample_frequency': self.sample_frequency,
              'bits_per_sample': self.bits_per_sample,
              'nr_audio_channels': self.nr_audio_channels,
              'resolution': self.resolution,
              'color_depth': self.color_depth,
              'protection': self.protection,
          }
          if remove_nones:
              # delete any elements that have a value of None to optimize size
              # of the returned structure
              nones = [k for k in content if content[k] is None]
              for k in nones:
                  del content[k]
          return content
docs: Return a dict representation of the `DidlResource`.
  
          Args:
              remove_nones (bool, optional): Optionally remove dictionary
                  elements when their value is `None`.
  
          Returns:
              dict: a dict representing the `DidlResource`