code: def basis_state(self, index_or_label):
          
          from qnet.algebra.core.state_algebra import BasisKet, TensorKet
          if isinstance(index_or_label, int):  # index
              ls_bases = [ls.basis_labels for ls in self.local_factors]
              label_tuple = list(cartesian_product(*ls_bases))[index_or_label]
              try:
                  return TensorKet(
                      *[BasisKet(label, hs=ls) for (ls, label)
                          in zip(self.local_factors, label_tuple)])
              except ValueError as exc_info:
                  raise IndexError(str(exc_info))
          else:  # label
              local_labels = index_or_label.split(",")
              if len(local_labels) != len(self.local_factors):
                  raise KeyError(
                      "label %s for Hilbert space %s must be comma-separated "
                      "concatenation of local labels" % (index_or_label, self))
              try:
                  return TensorKet(
                      *[BasisKet(label, hs=ls) for (ls, label)
                        in zip(self.local_factors, local_labels)])
              except ValueError as exc_info:
                  raise KeyError(str(exc_info))
docs: Return the basis state with the given index or label.
  
          Raises:
              .BasisNotSetError: if the Hilbert space has no defined basis
              IndexError: if there is no basis state with the given index
              KeyError: if there is not basis state with the given label