tensorflow_probability/python/internal/backend/numpy/internal/utils.py
def common_dtype(args_list, preferred_dtype=None):
  """Returns explict dtype from `args_list` if exists, else preferred_dtype."""
  dtype = None
  preferred_dtype = (None if preferred_dtype is None
                     else tf.as_dtype(preferred_dtype))
  for a in tf.nest.flatten(args_list):
    if hasattr(a, 'dtype'):
      dt = tf.as_dtype(a.dtype)
    else:
      continue
    if dtype is None:
      dtype = dt
    elif dtype != dt:
      raise TypeError('Found incompatible dtypes, {} and {}.'.format(dtype, dt))
  if dtype is None and preferred_dtype is None:
    return None
  return (preferred_dtype if dtype is None else dtype).as_numpy_dtype
def common_dtype(args_list, preferred_dtype=None):
  """Returns explict dtype from `args_list` if exists, else preferred_dtype."""
  dtype = None
  preferred_dtype = (None if preferred_dtype is None
                     else tf.as_dtype(preferred_dtype))
  for a in tf.nest.flatten(args_list):
    if hasattr(a, 'dtype'):
      dt = tf.as_dtype(a.dtype)
    else:
      continue
    if dtype is None:
      dtype = dt
    elif dtype != dt:
      raise TypeError('Found incompatible dtypes, {} and {}.'.format(dtype, dt))
  if dtype is None and preferred_dtype is None:
    return None
  return (preferred_dtype if dtype is None else dtype).as_numpy_dtype
Returns explict dtype from `args_list` if exists, else preferred_dtype.