<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def render_activity(activity, grouped_activity=None, *args, **kwargs):
 """ Given an activity, will attempt to render the matching template snippet for that activity's content object or will return a simple representation of the activity. Also takes an optional 'grouped_activity' argument that would match up with what is produced by utils.group_activity """

    template_name = 'activity_monitor/includes/models/{0.app_label}_{0.model}.html'.format(activity.content_type)
    try:
        tmpl = loader.get_template(template_name)
    except template.TemplateDoesNotExist:
        return None
    # we know we have a template, so render it
    content_object = activity.content_object
    return tmpl.render(Context({
        'activity': activity,
        'obj': content_object,
        'grouped_activity': grouped_activity
    }))