<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expanded(self):
 """Get JSON-LD expanded state."""

        # Ensure we can run outside a application/request context.
        if request:
            if 'expanded' in request.args:
                return True
            elif 'compacted' in request.args:
                return False
        return self._expanded