code: def check_data(data):
      """Check that the data dictionary passed during inference and
      criticism is valid.
      """
      if not isinstance(data, dict):
          raise TypeError("data must have type dict.")
  
      for key, value in six.iteritems(data):
          if (
              isinstance(key, tf.Tensor)
              and "Placeholder" in key.op.type
          ):
              if isinstance(value, RandomVariable):
                  raise TypeError(
                      "The value of a feed cannot be a ed.RandomVariable "
                      "object. "
                      "Acceptable feed values include Python scalars, "
                      "strings, lists, numpy ndarrays, or TensorHandles."
                  )
              elif isinstance(value, tf.Tensor):
                  raise TypeError(
                      "The value of a feed cannot be a tf.Tensor object. "
                      "Acceptable feed values include Python scalars, "
                      "strings, lists, numpy ndarrays, or TensorHandles."
                  )
          elif isinstance(key, (RandomVariable, tf.Tensor)):
              if isinstance(value, (RandomVariable, tf.Tensor)):
                  if not key.shape.is_compatible_with(value.shape):
                      raise TypeError(
                          "Key-value pair in data does not have same "
                          "shape: {}, {}".format(key.shape, value.shape)
                      )
                  elif key.dtype != value.dtype:
                      raise TypeError(
                          "Key-value pair in data does not have same "
                          "dtype: {}, {}".format(key.dtype, value.dtype)
                      )
              elif isinstance(
                  value, (float, list, int, np.ndarray, np.number, str)
              ):
                  if not key.shape.is_compatible_with(np.shape(value)):
                      raise TypeError(
                          "Key-value pair in data does not have same "
                          "shape: {}, {}".format(
                              key.shape, np.shape(value)
                          )
                      )
                  elif (
                      isinstance(value, (np.ndarray, np.number))
                      and not np.issubdtype(value.dtype, np.float)
                      and not np.issubdtype(value.dtype, np.int)
                      and not np.issubdtype(value.dtype, np.str)
                  ):
                      raise TypeError(
                          "Data value has an invalid dtype: "
                          "{}".format(value.dtype)
                      )
              else:
                  raise TypeError(
                      "Data value has an invalid type: "
                      "{}".format(type(value))
                  )
          else:
              raise TypeError(
                  "Data key has an invalid type: {}".format(type(key))
              )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import six
  import tensorflow
  from copy import deepcopy
  from edward.models.random_variable import RandomVariable
  from edward.models.random_variables import TransformedDistribution
  from edward.models import PointMass
  from edward.util.graphs import random_variables
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.framework.ops import set_shapes_for_outputs
  from tensorflow.python.util import compat
label_desc: Use image node_id 1 for calling a global function with example usage: check_data(data) without return types