class_docstr: A Type wrapper for `numpy.random.Generator`.
  
  The reason this exists (and `Generic` doesn't suffice) is that
  `Generator` objects that would appear to be equal do not compare equal
  with the ``==`` operator.
  
  This `Type` also works with a ``dict`` derived from
  `Generator.__get_state__`, unless the ``strict`` argument to `Type.filter`
  is explicitly set to ``True``.
class_docstr_tok: ["A","Type","wrapper","for","`","numpy.random.Generator","`",".","The","reason","this","exists","(","and","`","Generic","`","does","n't","suffice",")","is","that","`","Generator","`","objects","that","would","appear","to","be","equal","do","not","compare","equal","with","the","``","==","``","operator",".","This","`","Type","`","also","works","with","a","``","dict","``","derived","from","`","Generator.__get_state__","`",",","unless","the","``","strict","``","argument","to","`","Type.filter","`","is","explicitly","set","to","``","True","``","."]
docstr: XXX: This doesn't convert `data` to the same type of underlying RNG type
  as `self`.  It really only checks that `data` is of the appropriate type
  to be a valid `RandomGeneratorType`.
  
  In other words, it serves as a `Type.is_valid_value` implementation,
  but, because the default `Type.is_valid_value` depends on
  `Type.filter`, we need to have it here to avoid surprising circular
  dependencies in sub-classes.
docstr_tok: ["XXX",":","This","does","n't","convert","`","data","`","to","the","same","type","of","underlying","RNG","type","as","`","self","`",".","It","really","only","checks","that","`","data","`","is","of","the","appropriate","type","to","be","a","valid","`","RandomGeneratorType","`",".","In","other","words",",","it","serves","as","a","`","Type.is_valid_value","`","implementation",",","but",",","because","the","default","`","Type.is_valid_value","`","depends","on","`","Type.filter","`",",","we","need","to","have","it","here","to","avoid","surprising","circular","dependencies","in","sub-classes","."]
code: def filter(self, data, strict=False, allow_downcast=None):
      """
      XXX: This doesn't convert `data` to the same type of underlying RNG type
      as `self`.  It really only checks that `data` is of the appropriate type
      to be a valid `RandomGeneratorType`.
  
      In other words, it serves as a `Type.is_valid_value` implementation,
      but, because the default `Type.is_valid_value` depends on
      `Type.filter`, we need to have it here to avoid surprising circular
      dependencies in sub-classes.
      """
      if isinstance(data, np.random.Generator):
          return data
  
      if not strict and isinstance(data, dict):
          if "bit_generator" not in data:
              raise TypeError()
          else:
              bit_gen_key = data["bit_generator"]
  
              if hasattr(bit_gen_key, "_value"):
                  bit_gen_key = int(bit_gen_key._value)
                  bit_gen_key = numpy_bit_gens[bit_gen_key]
  
              gen_keys, state_keys = gen_states_keys[bit_gen_key]
  
              for key in gen_keys:
                  if key not in data:
                      raise TypeError()
  
              for key in state_keys:
                  if key not in data["state"]:
                      raise TypeError()
  
              return data
  
      raise TypeError()
  
imports: from typing import TypeVar
  import numpy
  import pytensor
  from pytensor.graph.type import Type
label_desc: Use image node_id 2 for calling the RandomGeneratorType obj's underlying member method code with example usage: obj.filter(data, strict, allow_downcast) and returns: data, data