<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tomask(self, pores=None, throats=None):
 r""" Convert a list of pore or throat indices into a boolean mask of the correct length Parameters pores or throats : array_like List of pore or throat indices. Only one of these can be specified at a time, and the returned result will be of the corresponding length. Returns ------- A boolean mask of length Np or Nt with True in the specified pore or throat locations. See Also -------- toindices Examples -------- 3 125 300 """

        if (pores is not None) and (throats is None):
            mask = self._tomask(element='pore', indices=pores)
        elif (throats is not None) and (pores is None):
            mask = self._tomask(element='throat', indices=throats)
        else:
            raise Exception('Cannot specify both pores and throats')
        return mask