<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def try_lock(self, timeout=0, lease_time=-1):
 """ Tries to acquire the lock. When the lock is not available, * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately. * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: * the lock is acquired by the current thread, or * the specified waiting time elapses. If lease time is provided, lock will be released after this time elapses. :param timeout: (long), maximum time in seconds to wait for the lock (optional). :param lease_time: (long), time in seconds to wait before releasing the lock (optional). :return: (bool), ``true`` if the lock was acquired and otherwise, ``false``. """

        return self._encode_invoke(lock_try_lock_codec, invocation_timeout=MAX_SIZE, lease=to_millis(lease_time),
                                   thread_id=thread_id(), timeout=to_millis(timeout),
                                   reference_id=self.reference_id_generator.get_and_increment())