code: def put(self, entity):
          
          if self._status != self._IN_PROGRESS:
              raise ValueError("Batch must be in progress to put()")
  
          if entity.key is None:
              raise ValueError("Entity must have a key")
  
          if self.project != entity.key.project:
              raise ValueError("Key must be from same project as batch")
  
          if entity.key.is_partial:
              entity_pb = self._add_partial_key_entity_pb()
              self._partial_key_entities.append(entity)
          else:
              entity_pb = self._add_complete_key_entity_pb()
  
          _assign_entity_to_pb(entity_pb, entity)
docs: Remember an entity's state to be saved during :meth:`commit`.
  
          .. note::
             Any existing properties for the entity will be replaced by those
             currently set on this instance.  Already-stored properties which do
             not correspond to keys set on this instance will be removed from
             the datastore.
  
          .. note::
             Property values which are "text" ('unicode' in Python2, 'str' in
             Python3) map to 'string_value' in the datastore;  values which are
             "bytes" ('str' in Python2, 'bytes' in Python3) map to 'blob_value'.
  
          When an entity has a partial key, calling :meth:`commit` sends it as
          an ``insert`` mutation and the key is completed. On return,
          the key for the ``entity`` passed in is updated to match the key ID
          assigned by the server.
  
          :type entity: :class:`google.cloud.datastore.entity.Entity`
          :param entity: the entity to be saved.
  
          :raises: :class:`~exceptions.ValueError` if the batch is not in
                   progress, if entity has no key assigned, or if the key's
                   ``project`` does not match ours.