code: def print_gate(gate: Gate, ndigits: int = 2,
                 file: TextIO = None) -> None:
      
      N = gate.qubit_nb
      gate_tensor = gate.vec.asarray()
      lines = []
      for index, amplitude in np.ndenumerate(gate_tensor):
          ket = "".join([str(n) for n in index[0:N]])
          bra = "".join([str(index[n]) for n in range(N, 2*N)])
          if round(abs(amplitude)**2, ndigits) > 0.0:
              lines.append('{} -> {} : {}'.format(bra, ket, amplitude))
      lines.sort(key=lambda x: int(x[0:N]))
      print('\n'.join(lines), file=file)
docs: Pretty print a gate tensor
  
      Args:
          gate:
          ndigits:
          file: Stream to which to write. Defaults to stdout