code: def test_convert_observed_data(input_dtype):
      """
      Ensure that convert_observed_data returns the dense array, masked array,
      graph variable, TensorVariable, or sparse matrix as appropriate.
      """
      # Create the various inputs to the function
      sparse_input = sps.csr_matrix(np.eye(3)).astype(input_dtype)
      dense_input = np.arange(9).reshape((3, 3)).astype(input_dtype)
  
      input_name = "input_variable"
      pytensor_graph_input = pt.as_tensor(dense_input, name=input_name)
      pandas_input = pd.DataFrame(dense_input)
  
      # All the even numbers are replaced with NaN
      missing_numpy_input = np.array(
          [[np.nan, 1, np.nan], [3, np.nan, 5], [np.nan, 7, np.nan]]
      )
      missing_pandas_input = pd.DataFrame(missing_numpy_input)
      masked_array_input = ma.array(
          dense_input, mask=(np.mod(dense_input, 2) == 0)
      )
  
      # Create a generator object. Apparently the generator object needs to
      # yield numpy arrays.
      square_generator = (
          np.array([i**2], dtype=int) for i in range(100)
      )
  
      # Alias the function to be tested
      func = convert_observed_data
  
      #####
      # Perform the various tests
      #####
      # Check function behavior with dense arrays and pandas dataframes
      # without missing values
      for input_value in [dense_input, pandas_input]:
          func_output = func(input_value)
          assert isinstance(func_output, np.ndarray)
          assert func_output.shape == input_value.shape
          npt.assert_allclose(func_output, dense_input)
  
      # Check function behavior with sparse matrix inputs
      sparse_output = func(sparse_input)
      assert sps.issparse(sparse_output)
      assert sparse_output.shape == sparse_input.shape
      npt.assert_allclose(
          sparse_output.toarray(), sparse_input.toarray()
      )
  
      # Check function behavior when using masked array inputs and pandas
      # objects with missing data
      for input_value in [
          missing_numpy_input,
          masked_array_input,
          missing_pandas_input,
      ]:
          func_output = func(input_value)
          assert isinstance(func_output, ma.core.MaskedArray)
          assert func_output.shape == input_value.shape
          npt.assert_allclose(func_output, masked_array_input)
  
      # Check function behavior with PyTensor graph variable
      pytensor_output = func(pytensor_graph_input)
      assert isinstance(pytensor_output, Variable)
      npt.assert_allclose(
          pytensor_output.eval(), pytensor_graph_input.eval()
      )
      intX = pm.pytensorf._conversion_map[pytensor.config.floatX]
      if (
          dense_input.dtype == intX
          or dense_input.dtype == pytensor.config.floatX
      ):
          assert (
              pytensor_output.owner is None
          )  # func should not have added new nodes
          assert pytensor_output.name == input_name
      else:
          assert (
              pytensor_output.owner is not None
          )  # func should have casted
          assert pytensor_output.owner.inputs[0].name == input_name
  
      if "float" in input_dtype:
          assert pytensor_output.dtype == pytensor.config.floatX
      else:
          assert pytensor_output.dtype == intX
  
      # Check function behavior with generator data
      generator_output = func(square_generator)
  
      # Output is wrapped with `pm.floatX`, and this unwraps
      wrapped = generator_output.owner.inputs[0]
      # Make sure the returned object has .set_gen and .set_default methods
      assert hasattr(wrapped, "set_gen")
      assert hasattr(wrapped, "set_default")
      # Make sure the returned object is an PyTensor TensorVariable
      assert isinstance(wrapped, TensorVariable)
  
imports: import warnings
  import numpy
  import numpy.ma
  import numpy.testing
  import pandas
  import pytensor
  import pytensor.tensor
  import pytest
  import scipy.sparse
  from pytensor import scan, shared
  from pytensor.compile import UnusedInputError
  from pytensor.compile.builders import OpFromGraph
  from pytensor.graph.basic import Variable
  from pytensor.tensor.random.basic import normal, uniform
  from pytensor.tensor.random.var import RandomStateSharedVariable
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1
  from pytensor.tensor.variable import TensorVariable
  import pymc
  from pymc.distributions.dist_math import check_parameters
  from pymc.distributions.distribution import SymbolicRandomVariable
  from pymc.exceptions import NotConstantValueError
  from pymc.logprob.utils import ParameterValueError
  from pymc.pytensorf import collect_default_updates, compile_pymc, constant_fold, convert_observed_data, extract_obs_data, replace_rng_nodes, replace_vars_in_graphs, reseed_rngs, walk_model
  from pymc.vartypes import int_types
label_desc: Use image node_id 6 for calling a global function with example usage: test_convert_observed_data(input_dtype) without return types