<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _out_batch_cmdidx(cmd_array):
 """Raise `IndexError` if OUT_BATCH is used multiple time :returns: OUT_BATCH cmdidx (None if OUT_BATCH is not in `cmd_array`) $ cat a.txt > OUT_BATCH => 3 """

        out_batch_cmdidx = None
        for cmdidx, tok in enumerate(cmd_array):
            mat = BatchCommand.out_batch_pat.match(tok)
            if mat:
                if out_batch_cmdidx:
                    raise IndexError(
                        'OUT_BATCH is used multiple times in command below:%s$ %s' %
                        (os.linesep, list2cmdline(cmd_array)))
                out_batch_cmdidx = cmdidx
        return out_batch_cmdidx