code: def lease(self, lease_time, num_tasks, group_by_tag=False, tag=None, client=None):
          
          client = self._require_client(client)
  
          if group_by_tag:
              query_params = {"leaseSecs": lease_time, "numTasks": num_tasks, "groupByTag": group_by_tag, "tag": tag}
          else:
              query_params = {"leaseSecs": lease_time, "numTasks": num_tasks}
          response = client.connection.api_request(method='POST', path=self.path + "/tasks/lease",
                                                   query_params=query_params)
  
          for item in response.get('items', []):
              id = item.get('id')
              task = Task(id, taskqueue=self)
              task._set_properties(item)
              yield task
docs: Acquires a lease on the topmost N unowned tasks in the specified queue.
  
          :type lease_time: int
          :param lease_time: How long to lease this task, in seconds.
  
          :type num_tasks: int
          :param num_tasks: The number of tasks to lease.
  
          :type group_by_tag: bool
          :param group_by_tag: Optional. When True, returns tasks of the same tag. Specify which tag by using the
          tag parameter. If tag is not specified, returns tasks of the same tag as the oldest task in the queue.
  
          :type tag: string
          :param tag: Optional. Only specify tag if groupByTag is true. If groupByTag is true and tag is not specified,
          the tag is assumed to be that of the oldest task by ETA. I.e., the first available tag.
  
          :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
          :param client: Optional. The client to use.  If not passed, falls back
                         to the ``client`` stored on the task's taskqueue.
  
          :rtype: :class:`_TaskIterator`.
          :returns: An iterator of tasks.