code: def from_element(cls, element):
          
          def _int_helper(name):
              """Try to convert the name attribute to an int, or None."""
              result = element.get(name)
              if result is not None:
                  try:
                      return int(result)
                  except ValueError:
                      raise DIDLMetadataError(
                          'Could not convert {0} to an integer'.format(name))
              else:
                  return None
  
          content = {}
          # required
          content['protocol_info'] = element.get('protocolInfo')
          if content['protocol_info'] is None:
              raise DIDLMetadataError('Could not create Resource from Element: '
                                      'protocolInfo not found (required).')
          # Optional
          content['import_uri'] = element.get('importUri')
          content['size'] = _int_helper('size')
          content['duration'] = element.get('duration')
          content['bitrate'] = _int_helper('bitrate')
          content['sample_frequency'] = _int_helper('sampleFrequency')
          content['bits_per_sample'] = _int_helper('bitsPerSample')
          content['nr_audio_channels'] = _int_helper('nrAudioChannels')
          content['resolution'] = element.get('resolution')
          content['color_depth'] = _int_helper('colorDepth')
          content['protection'] = element.get('protection')
          content['uri'] = element.text
          return cls(**content)
docs: Set the resource properties from a ``<res>`` element.
  
          Args:
              element (~xml.etree.ElementTree.Element): The ``<res>``
                  element