code: def inject(self, element, name=None, layer=None):
          
          if not is_integer(layer):
              raise TypeError("The layer for insertion must be an int.")
          elif layer != 0 and layer != len(self._queue):
              raise NotImplementedError(
                  "You can only insert to the beginning or end of a %s, currently. "
                  "You tried to insert to %d, but only 0 and %d are permitted. " % (
                      type(self),
                      layer,
                      len(self._queue),
                  )
              )
  
          self.add(element, name=name)
  
          if layer == 0:
              if name is None:
                  name = element
              self._queue.move_to_end(name, last=False)
          elif layer == len(self._queue):
              return
          else:
              raise AssertionError("Impossible to reach: earlier validation raises an error")
docs: Inject a named element to an arbitrary layer in the onion.
  
          The current implementation only supports insertion at the innermost layer,
          or at the outermost layer. Note that inserting to the outermost is equivalent
          to calling :meth:`add` .