code: def kernel_input(
      draw,
      batch_shape,
      example_dim=None,
      example_ndims=None,
      feature_dim=None,
      feature_ndims=None,
      enable_vars=False,
      name=None,
  ):
      """Strategy for drawing arbitrary Kernel input.
  
      In order to avoid duplicates (or even numerically near-duplicates), we
      generate inputs on a grid. We let hypothesis generate the number of grid
      points and distance between grid points, within some reasonable pre-defined
      ranges. The result will be a batch of example sets, within which each set of
      examples has no duplicates (but no such duplication avoidance is applied
      accross batches).
  
      Args:
        draw: Hypothesis function supplied by `@hps.composite`.
        batch_shape: `TensorShape`. The batch shape of the resulting
          kernel input.
        example_dim: Optional Python int giving the size of each example dimension.
          If omitted, Hypothesis will choose one.
        example_ndims: Optional Python int giving the number of example dimensions
          of the input. If omitted, Hypothesis will choose one.
        feature_dim: Optional Python int giving the size of each feature dimension.
          If omitted, Hypothesis will choose one.
        feature_ndims: Optional Python int stating the number of feature dimensions
          inputs will have. If omitted, Hypothesis will choose one.
        enable_vars: If `False`, the returned parameters are all Tensors, never
          Variables or DeferredTensor.
        name: Name to give the variable.
  
      Returns:
        kernel_input: A strategy for drawing kernel_input with the prescribed shape
          (or an arbitrary one if omitted).
      """
      if example_ndims is None:
          example_ndims = draw(hps.integers(min_value=1, max_value=2))
      if example_dim is None:
          example_dim = draw(hps.integers(min_value=2, max_value=4))
  
      if feature_ndims is None:
          feature_ndims = draw(hps.integers(min_value=0, max_value=2))
      if feature_dim is None:
          feature_dim = draw(hps.integers(min_value=2, max_value=4))
  
      batch_shape = tensorshape_util.as_list(batch_shape)
      example_shape = [example_dim] * example_ndims
      feature_shape = [feature_dim] * feature_ndims
  
      batch_size = int(np.prod(batch_shape))
      example_size = example_dim**example_ndims
      feature_size = feature_dim**feature_ndims
  
      # We would like each batch of examples to be unique, to avoid computing kernel
      # matrices that are semi-definite. hypothesis.extra.numpy.arrays doesn't have
      # a sense of tolerance, so we need to do some extra work to get points
      # sufficiently far from each other.
      grid_size = draw(hps.integers(min_value=10, max_value=100))
      grid_spacing = draw(hps.floats(min_value=1e-2, max_value=2))
      hp.note(
          "Grid size {} and spacing {}".format(grid_size, grid_spacing)
      )
  
      def _grid_indices_to_values(grid_indices):
          return grid_spacing * (
              np.array(grid_indices, dtype=np.float64)
              - np.float64(grid_size)
          )
  
      # We'll construct the result by stacking onto flattened batch, example and
      # feature dims, then reshape to unflatten at the end.
      result = np.zeros([0, example_size, feature_size])
      for _ in range(batch_size):
          seen = set()
          index_array_strategy = hps.tuples(
              *([hps.integers(0, grid_size + 1)] * feature_size)
          ).filter(
              lambda x, seen=seen: x not in seen
          )  # Default param to sate pylint.
          examples = np.zeros([1, 0, feature_size])
          for _ in range(example_size):
              feature_grid_locations = draw(index_array_strategy)
              seen.add(feature_grid_locations)
              example = _grid_indices_to_values(feature_grid_locations)
              example = example[np.newaxis, np.newaxis, ...]
              examples = np.concatenate([examples, example], axis=1)
          result = np.concatenate([result, examples], axis=0)
      result = np.reshape(
          result, batch_shape + example_shape + feature_shape
      )
  
      if enable_vars and draw(hps.booleans()):
          result = tf.Variable(result, name=name)
          if draw(hps.booleans()):
              result = tfp_hps.defer_and_count_usage(result)
      return result
  
imports: import collections
  import contextlib
  import inspect
  import logging
  import re
  import hypothesis
  from hypothesis.extra import numpy
  import hypothesis.strategies
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.distributions import marginal_fns
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import psd_kernels
label_desc: Use image node_id 2 for calling a global function with example usage: kernel_input(draw, batch_shape, example_dim, example_ndims, feature_dim, feature_ndims, enable_vars, name) and returns: result, unknown