class_docstr: Base class for implementations of deterministic finite
  automata.
  
  This is abstract to allow for the possibility of states
  being calculated lazily as we traverse the DFA (which
  we make heavy use of in our L* implementation - see
  lstar.py for details).
  
  States can be of any hashable type.
class_docstr_tok: ["Base","class","for","implementations","of","deterministic","finite","automata",".","This","is","abstract","to","allow","for","the","possibility","of","states","being","calculated","lazily","as","we","traverse","the","DFA","(","which","we","make","heavy","use","of","in","our","L","*","implementation","-","see","lstar.py","for","details",")",".","States","can","be","of","any","hashable","type","."]
docstr: Returns the number of strings of length ``length``
  that are accepted when starting from state ``state``.
docstr_tok: ["Returns","the","number","of","strings","of","length","``","length","``","that","are","accepted","when","starting","from","state","``","state","``","."]
code: def count_strings(self, state, length):
      """Returns the number of strings of length ``length``
      that are accepted when starting from state ``state``."""
      assert length >= 0
      cache = self.__cache("count_strings")
  
      try:
          return cache[state, length]
      except KeyError:
          pass
  
      pending = [(state, length)]
      seen = set()
      i = 0
  
      while i < len(pending):
          s, n = pending[i]
          i += 1
          if n > 0:
              for t in self.successor_states(s):
                  key = (t, n - 1)
                  if key not in cache and key not in seen:
                      pending.append(key)
                      seen.add(key)
  
      while pending:
          s, n = pending.pop()
          if n == 0:
              cache[s, n] = int(self.is_accepting(s))
          else:
              cache[s, n] = sum(
                  cache[t, n - 1] * k
                  for t, k in self.transition_counts(s)
              )
  
      return cache[state, length]
  
imports: import threading
  from collections import Counter, defaultdict, deque
  from math import inf
  from hypothesis.internal.reflection import proxies
label_desc: Use image node_id 13 for calling the DFA obj's underlying member method code with example usage: obj.count_strings(state, length) and returns: cache, cache