code: def from_dtype(dtype):
      # type: (np.dtype) -> st.SearchStrategy[Any]
      """Creates a strategy which can generate any value of the given dtype."""
      check_type(np.dtype, dtype, "dtype")
      # Compound datatypes, eg 'f4,f4,f4'
      if dtype.names is not None:
          # mapping np.void.type over a strategy is nonsense, so return now.
          return st.tuples(
              *[
                  from_dtype(dtype.fields[name][0])
                  for name in dtype.names
              ]
          )
  
      # Subarray datatypes, eg '(2, 3)i4'
      if dtype.subdtype is not None:
          subtype, shape = dtype.subdtype
          return arrays(subtype, shape)
  
      # Scalar datatypes
      if dtype.kind == "b":
          result = st.booleans()  # type: SearchStrategy[Any]
      elif dtype.kind == "f":
          if dtype.itemsize == 2:
              result = st.floats(width=16)
          elif dtype.itemsize == 4:
              result = st.floats(width=32)
          else:
              result = st.floats()
      elif dtype.kind == "c":
          if dtype.itemsize == 8:
              float32 = st.floats(width=32)
              result = st.builds(complex, float32, float32)
          else:
              result = st.complex_numbers()
      elif dtype.kind in ("S", "a"):
          # Numpy strings are null-terminated; only allow round-trippable values.
          # `itemsize == 0` means 'fixed length determined at array creation'
          result = st.binary(max_size=dtype.itemsize or None).filter(
              lambda b: b[-1:] != b"\0"
          )
      elif dtype.kind == "u":
          result = st.integers(
              min_value=0, max_value=2 ** (8 * dtype.itemsize) - 1
          )
      elif dtype.kind == "i":
          overflow = 2 ** (8 * dtype.itemsize - 1)
          result = st.integers(
              min_value=-overflow, max_value=overflow - 1
          )
      elif dtype.kind == "U":
          # Encoded in UTF-32 (four bytes/codepoint) and null-terminated
          result = st.text(
              max_size=(dtype.itemsize or 0) // 4 or None
          ).filter(lambda b: b[-1:] != "\0")
      elif dtype.kind in ("m", "M"):
          if "[" in dtype.str:
              res = st.just(dtype.str.split("[")[-1][:-1])
          else:
              res = st.sampled_from(TIME_RESOLUTIONS)
          result = st.builds(
              dtype.type, st.integers(-(2**63), 2**63 - 1), res
          )
      else:
          raise InvalidArgument(
              "No strategy inference for {}".format(dtype)
          )
      return result.map(dtype.type)
  
imports: from __future__ import absolute_import, division, print_function
  import math
  import re
  from collections import namedtuple
  import numpy
  import hypothesis.internal.conjecture.utils
  import hypothesis.strategies._internal.core
  from hypothesis import Verbosity, assume
  from hypothesis._settings import note_deprecation
  from hypothesis.errors import InvalidArgument
  from hypothesis.internal.compat import PY2, hrange, integer_types, quiet_raise, string_types
  from hypothesis.internal.coverage import check_function
  from hypothesis.internal.reflection import proxies, reserved_means_kwonly_star
  from hypothesis.internal.validation import check_type, check_valid_interval
  from hypothesis.reporting import current_verbosity
  from hypothesis.strategies._internal import SearchStrategy
  from hypothesis.utils.conventions import UniqueIdentifier, not_set
label_desc: Use image node_id 1 for calling a global function with example usage: from_dtype(dtype) and returns: result, st, arrays