docs: def select_by_index(self, val, level=0, squeeze=False, filter=False, return_mask=False):
          """
          Select or filter elements of the Series by index values (across levels, if multi-index).
  
          The index is a property of a Series object that assigns a value to each position within
          the arrays stored in the records of the Series. This function returns a new Series where,
          within each record, only the elements indexed by a given value(s) are retained. An index
          where each value is a list of a fixed length is referred to as a 'multi-index',
          as it provides multiple labels for each index location. Each of the dimensions in these
          sublists is a 'level' of the multi-index. If the index of the Series is a multi-index, then
          the selection can proceed by first selecting one or more levels, and then selecting one
          or more values at each level.
  
          Parameters
          ----------
          val : list of lists
              Specifies the selected index values. List must contain one list for each level of the
              multi-index used in the selection. For any singleton lists, the list may be replaced
              with just the integer.
  
          level : list of ints, optional, default=0
              Specifies which levels in the multi-index to use when performing selection. If a single
              level is selected, the list can be replaced with an integer. Must be the same length
              as val.
  
          squeeze : bool, optional, default=False
              If True, the multi-index of the resulting Series will drop any levels that contain
              only a single value because of the selection. Useful if indices are used as unique
              identifiers.
  
          filter : bool, optional, default=False
              If True, selection process is reversed and all index values EXCEPT those specified
              are selected.
  
          return_mask : bool, optional, default=False
              If True, return the mask used to implement the selection.
          """
          try:
              level[0]
          except:
              level = [level]
          try:
              val[0]
          except:
              val = [val]
  
          remove = []
          if len(level) == 1:
              try:
                  val[0][0]
              except:
                  val = [val]
              if squeeze and not filter and len(val) == 1:
                  remove.append(level[0])
          else:
              for i in range(len(val)):
                  try:
                      val[i][0]
                  except:
                      val[i] = [val[i]]
                  if squeeze and not filter and len(val[i]) == 1:
                      remove.append(level[i])
  
          if len(level) != len(val):
              raise ValueError("List of levels must be same length as list of corresponding values")
  
          p = product(*val)
          selected = set([x for x in p])
  
          masks, ind = self._makemasks(index=self.index, level=level)
          nmasks = len(masks)
          masks = array([masks[x] for x in range(nmasks) if tuple(ind[x]) in selected])
  
          final_mask = masks.any(axis=0)
          if filter:
              final_mask = logical_not(final_mask)
  
          indFinal = array(self.index)
          if len(indFinal.shape) == 1:
              indFinal = array(indFinal, ndmin=2).T
          indFinal = indFinal[final_mask]
  
          if squeeze:
              indFinal = delete(indFinal, remove, axis=1)
  
          if len(indFinal[0]) == 1:
              indFinal = ravel(indFinal)
  
          elif len(indFinal[1]) == 0:
              indFinal = arange(sum(final_mask))
  
          result = self.map(lambda v: v[final_mask], index=indFinal)
  
          if return_mask:
              return result, final_mask
          else:
              return result