code: def _get_gate_tensor_and_qubits(gate: Gate):
      
      if len(gate.params) > 0:
          matrix = QUANTUM_GATES[gate.name](*gate.params)
      else:
          matrix = QUANTUM_GATES[gate.name]
  
      qubit_inds = [q.index for q in gate.qubits]
  
      # e.g. 2-qubit matrix is 4x4; turns into (2,2,2,2) tensor.
      tensor = np.reshape(matrix, (2,) * len(qubit_inds) * 2)
  
      return tensor, qubit_inds
docs: Given a gate ``Instruction``, turn it into a matrix and extract qubit indices.
  
      :param gate: the instruction
      :return: tensor, qubit_inds.