<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _regular_gate(self, gate, lines, ctrl_lines, used_lines):
 """ Draw a regular gate. :param string gate: Gate to draw. :param lines: Lines the gate acts on. :type: list[int] :param int ctrl_lines: Control lines. :param int used_lines: The lines that are actually involved in the gate. :return: LaTeX string drawing a regular gate at the given location. :rtype: string """

        imax = max(lines)
        imin = min(lines)

        delta_pos = self._gate_offset(gate)
        gate_width = self._gate_width(gate)
        gate_height = self._gate_height(gate)

        name = self._gate_name(gate)

        lines = list(range(imin, imax + 1))

        tex_str = ""
        pos = self.pos[lines[0]]

        node_str = "\n\\node[none] ({}) at ({},-{}) {{}};"
        for l in lines:
            node1 = node_str.format(self._op(l), pos, l)
            if l in used_lines:
                tex_str += self._phase(l, pos)
            node2 = ("\n\\node[none,minimum height={}cm,outer sep=0] ({}) at"
                     " ({},-{}) {{}};").format(gate_height, self._op(l, offset=1), pos + gate_width / 2., l)
            node3 = node_str.format(self._op(l, offset=2), pos + gate_width, l)
            tex_str += node1 + node2 + node3
        tex_str += ("\n\\draw[operator,edgestyle,outer sep={width}cm]"
                    " ([yshift={half_height}cm]{op1})"
                    " rectangle ([yshift=-{half_height}cm]{op2}) node[pos=.5]{{\\verb|{name}|}};"
                    ).format(width=gate_width, op1=self._op(imin), op2=self._op(imax, offset=2),
                             half_height=.5 * gate_height, name=name)
        for l in lines:
            self.pos[l] = pos + gate_width / 2.
            self.op_count[l] += 3
        for l in range(min(ctrl_lines + lines), max(ctrl_lines + lines) + 1):
            self.pos[l] = pos + delta_pos + gate_width
        return tex_str