code: def instrument(self, package, options=None, runner=None, handler=None):
          
          if runner is None:
              runner = DEFAULT_INSTRUMENTATION_RUNNER
          if options is None:
              options = {}
  
          options_list = []
          for option_key, option_value in options.items():
              options_list.append('-e %s %s' % (option_key, option_value))
          options_string = ' '.join(options_list)
  
          instrumentation_command = 'am instrument -r -w %s %s/%s' % (
              options_string, package, runner)
          logging.info('AndroidDevice|%s: Executing adb shell %s', self.serial,
                       instrumentation_command)
          if handler is None:
              # Flow kept for backwards-compatibility reasons
              self._exec_adb_cmd(
                  'shell',
                  instrumentation_command,
                  shell=False,
                  timeout=None,
                  stderr=None)
          else:
              return self._execute_adb_and_process_stdout(
                  'shell', instrumentation_command, shell=False, handler=handler)
docs: Runs an instrumentation command on the device.
  
          This is a convenience wrapper to avoid parameter formatting.
  
          Example:
  
          .. code-block:: python
  
              device.instrument(
                  'com.my.package.test',
                  options = {
                      'class': 'com.my.package.test.TestSuite',
                  },
              )
  
          Args:
              package: string, the package of the instrumentation tests.
              options: dict, the instrumentation options including the test
                  class.
              runner: string, the test runner name, which defaults to
                  DEFAULT_INSTRUMENTATION_RUNNER.
              handler: optional func, when specified the function is used to parse
                  the instrumentation stdout line by line as the output is
                  generated; otherwise, the stdout is simply returned once the
                  instrumentation is finished.
  
          Returns:
              The stdout of instrumentation command or the stderr if the handler
                  is set.