def get_linked_metadata(obj, name=None, context=None, site=None, language=None):
<EOL>Metadata = _get_metadata_model(name)<EOL>InstanceMetadata = Metadata._meta.get_model('<STR_LIT>')<EOL>ModelMetadata = Metadata._meta.get_model('<STR_LIT>')<EOL>content_type = ContentType.objects.get_for_model(obj)<EOL>instances = []<EOL>if InstanceMetadata is not None:<EOL><INDENT>try:<EOL><INDENT>instance_md = InstanceMetadata.objects.get(_content_type=content_type, _object_id=obj.pk)<EOL><DEDENT>except InstanceMetadata.DoesNotExist:<EOL><INDENT>instance_md = InstanceMetadata(_content_object=obj)<EOL><DEDENT>instances.append(instance_md)<EOL><DEDENT>if ModelMetadata is not None:<EOL><INDENT>try:<EOL><INDENT>model_md = ModelMetadata.objects.get(_content_type=content_type)<EOL><DEDENT>except ModelMetadata.DoesNotExist:<EOL><INDENT>model_md = ModelMetadata(_content_type=content_type)<EOL><DEDENT>instances.append(model_md)    <EOL><DEDENT>return FormattedMetadata(Metadata, instances, '<STR_LIT>', site, language)<EOL>
Gets metadata linked from the given object.