code: def test_cast_to_dtype_precision_issue() -> None:
      """
      TensorFlow's tf.cast(value, dtype) implicitly does a tf.convert_to_tensor(value)
      *before* the cast when the value is not a tensor already. When value is a python float,
      this results in the following behaviour:
  
      >>> tf.cast(0.2, tf.float64)
      <tf.Tensor: id=37, shape=(), dtype=float64, numpy=0.20000000298023224>
  
      instead of the expected expansion of 0.2 to float64 precision that you get when
      passing in an object that already carries dtype information, such as a numpy array
      (which has float64 precision by default):
  
      >>> tf.cast(np.array(0.2), tf.float64)
      <tf.Tensor: id=40, shape=(), dtype=float64, numpy=0.2>
  
      This affected *all* gpflow.Parameter objects, resulting in numerical discrepancies
      between GPflow 1 and 2, due to the pass through _cast_to_dtype, which is now fixed.
      This is the corresponding regression test.
      """
      p = gpflow.Parameter(0.2, dtype=np.float64)
      actual_value = p.numpy()
      assert actual_value.dtype == np.float64
      expected_value = np.float64(0.2)
      assert actual_value == expected_value
  
imports: import tempfile
  from typing import Sequence
  import numpy
  import pytest
  import tensorflow
  import tensorflow_probability
  import gpflow
  from gpflow.base import AnyNDArray, PriorOn, TensorData
  from gpflow.config import default_float
  from gpflow.utilities import positive, triangular
label_desc: Use image node_id 2 for calling a global function with example usage: test_cast_to_dtype_precision_issue() without return types