code: def to_fock_representation(self, index_symbol='n', max_terms=None):
          
          phase_factor = sympy.exp(
              sympy.Rational(-1, 2) * self.ampl * self.ampl.conjugate())
          if not isinstance(index_symbol, IdxSym):
              index_symbol = IdxSym(index_symbol)
          n = index_symbol
          if max_terms is None:
              index_range = IndexOverFockSpace(n, hs=self._hs)
          else:
              index_range = IndexOverRange(n, 0, max_terms-1)
          term = (
              (self.ampl**n / sympy.sqrt(sympy.factorial(n))) *
              BasisKet(FockIndex(n), hs=self._hs))
          return phase_factor * KetIndexedSum(term, index_range)
docs: Return the coherent state written out as an indexed sum over Fock
          basis states