docs: def duplicate(self, contributor=None, inherit_collections=False):
          """Duplicate (make a copy)."""
          duplicate = Entity.objects.get(id=self.id)
          duplicate.pk = None
          duplicate.slug = None
          duplicate.name = 'Copy of {}'.format(self.name)
          duplicate.duplicated = now()
          if contributor:
              duplicate.contributor = contributor
  
          duplicate.save(force_insert=True)
  
          assign_contributor_permissions(duplicate)
  
          # Override fields that are automatically set on create.
          duplicate.created = self.created
          duplicate.save()
  
          # Duplicate entity's data objects.
          data = get_objects_for_user(contributor, 'view_data', self.data.all())  # pylint: disable=no-member
          duplicated_data = data.duplicate(contributor)
          duplicate.data.add(*duplicated_data)
  
          if inherit_collections:
              collections = get_objects_for_user(
                  contributor,
                  'add_collection',
                  self.collections.all()  # pylint: disable=no-member
              )
              for collection in collections:
                  collection.entity_set.add(duplicate)
                  copy_permissions(collection, duplicate)
                  collection.data.add(*duplicated_data)
                  for datum in duplicated_data:
                      copy_permissions(collection, datum)
  
          return duplicate