code: def test_ScanArgs():
      with pytest.raises(TypeError):
          ScanArgs.from_node(pt.ones(2).owner)
  
      hmm_model_env = create_test_hmm()
      scan_args = hmm_model_env["scan_args"]
      scan_op = hmm_model_env["scan_op"]
  
      # Make sure we can get alternate variables
      test_v = scan_args.outer_out_sit_sot[0]
      alt_test_v = scan_args.get_alt_field(test_v, "inner_out")
      assert alt_test_v == scan_args.inner_out_sit_sot[0]
  
      alt_test_v = scan_args.get_alt_field(test_v, "outer_in")
      assert alt_test_v == scan_args.outer_in_sit_sot[0]
  
      # Check the `__repr__` and `__str__`
      scan_args_repr = repr(scan_args)
      # Just make sure it doesn't err-out
      assert scan_args_repr.startswith("ScanArgs")
  
      # Check the properties that allow us to use
      # `Scan.get_oinp_iinp_iout_oout_mappings` as-is to implement
      # `ScanArgs.var_mappings`
      assert scan_args.n_nit_sot == scan_op.info.n_nit_sot
      assert scan_args.n_mit_mot == scan_op.info.n_mit_mot
      # The `scan_args` base class always clones the inner-graph;
      # here we make sure it doesn't (and that all the inputs are the same)
      assert scan_args.inputs == scan_op.inner_inputs
      assert scan_args.info == scan_op.info
  
      # Check that `ScanArgs.find_among_fields` works
      test_v = scan_op.inner_seqs(scan_op.inner_inputs)[1]
      field_info = scan_args.find_among_fields(test_v)
      assert field_info.name == "inner_in_seqs"
      assert field_info.index == 1
      assert field_info.inner_index is None
      assert scan_args.inner_inputs[field_info.agg_index] == test_v
  
      test_l = scan_op.inner_non_seqs(scan_op.inner_inputs)
      # We didn't index this argument, so it's a `list` (i.e. bad input)
      field_info = scan_args.find_among_fields(test_l)
      assert field_info is None
  
      test_v = test_l[0]
      field_info = scan_args.find_among_fields(test_v)
      assert field_info.name == "inner_in_non_seqs"
      assert field_info.index == 0
      assert field_info.inner_index is None
      assert scan_args.inner_inputs[field_info.agg_index] == test_v
  
      scan_args_copy = copy(scan_args)
      assert scan_args_copy is not scan_args
      assert scan_args_copy == scan_args
  
      assert scan_args_copy != test_v
      scan_args_copy.outer_in_seqs.pop()
      assert scan_args_copy != scan_args
  
file_path: pytensor/tests/scan/test_utils.py
imports: from copy import copy
  import numpy
  import pytest
  import pytensor
  from pytensor import tensor
  from pytensor.scan.utils import ScanArgs
label_desc: Use image node_id 3 for calling a global function with example usage: test_ScanArgs() without return types