code: def elem_remove(self, idx=None):
          
          if idx is not None:
              if idx in self.uid:
                  key = idx
                  item = self.uid[idx]
              else:
                  self.log('The item <{:s}> does not exist.'.format(idx), ERROR)
                  return None
          else:
              return None
  
          convert = False
          if isinstance(self.__dict__[self._params[0]], matrix):
              self._param_to_list()
              convert = True
  
          # self.n -= 1
          self.uid.pop(key, '')
          self.idx.pop(item)
          self.mdl_from.pop(item)
          self.mdl_to.pop(item)
  
          for x, y in self.uid.items():
              if y > item:
                  self.uid[x] = y - 1
  
          for param in self._data:
              self.__dict__[param].pop(item)
  
          for param in self._service:
              if len(self.__dict__[param]) == (self.n + 1):
                  if isinstance(self.__dict__[param], list):
                      self.__dict__[param].pop(item)
                  elif isinstance(self.__dict__[param], matrix):
                      service = list(self.__dict__[param])
                      service.pop(item)
                      self.__dict__[param] = matrix(service)
  
          for x in self._states:
              if len(self.__dict__[x]):
                  self.__dict__[x].pop(item)
  
          for y in self._algebs:
              if self.__dict__[y]:
                  self.__dict__[y].pop(item)
  
          for key, param in self._ac.items():
              if isinstance(param, list):
                  for subparam in param:
                      if len(self.__dict__[subparam]):
                          self.__dict__[subparam].pop(item)
              else:
                  self.__dict__[param].pop(item)
  
          for key, param in self._dc.items():
              self.__dict__[param].pop(item)
  
          self.name.pop(item)
          if convert and self.n:
              self._param_to_matrix()
docs: Remove elements labeled by idx from this model instance.
  
          :param list,matrix idx: indices of elements to be removed
          :return: None