docs: def safe_series_resistor_index_read(f, self, channel, resistor_index=None):
      '''
      This decorator checks the resistor-index from the current context _(i.e.,
      the result of `self.series_resistor_index`)_.  If the resistor-index
      specified by the `resistor_index` keyword argument is different than the
      current context value, the series-resistor-index is temporarily set to the
      value of `resistor_index` to execute the wrapped function before restoring
      back to the original value.
      '''
      if resistor_index is not None:
          original_resistor_index = self.series_resistor_index(channel)
          # Save state of resistor-index
          if resistor_index != original_resistor_index:
              self.set_series_resistor_index(channel, resistor_index)
  
      value = f(self, channel)
  
      if (resistor_index is not None and
              resistor_index != original_resistor_index):
          # Restore state of resistor-index
          self.set_series_resistor_index(channel, original_resistor_index)
      return value