code: def test_simplify_clip_cast():
      def before1():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "uint8")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      def expected1():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          return relay.Function([x], clip)
  
      def before2():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "uint8")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      def expected2():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          return relay.Function([x], clip)
  
      def before3():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "uint8")
          cast = relay.cast(cast, "int16")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      def expected3():
          x = relay.var("x", shape=(4, 8), dtype="int32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          return relay.Function([x], clip)
  
      def before4():
          x = relay.var("x", shape=(4, 8), dtype="float32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "uint8")
          cast = relay.cast(cast, "int16")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      def expected4():
          x = relay.var("x", shape=(4, 8), dtype="float32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "int32")
          return relay.Function([x], cast)
  
      def before5():
          x = relay.var("x", shape=(4, 8), dtype="float32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "int8")
          cast = relay.cast(cast, "int16")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      def expected5():
          x = relay.var("x", shape=(4, 8), dtype="float32")
          clip = relay.clip(x, a_min=0.0, a_max=255.0)
          cast = relay.cast(clip, "int8")
          cast = relay.cast(cast, "int32")
          return relay.Function([x], cast)
  
      for before, expected in [
          [before1(), expected1()],
          [before2(), expected2()],
          [before3(), expected3()],
          [before4(), expected4()],
          [before5(), expected5()],
      ]:
          after = run_opt_pass(before, transform.SimplifyExpr())
          expected = run_opt_pass(expected, transform.InferType())
          assert tvm.ir.structural_equal(
              after, expected
          ), "\nafter: {} \nexpected: {}".format(after, expected)
  
imports: from math import sqrt
  import pytest
  import tvm
  from tvm import relay
  from tvm.relay import transform
  from tvm.relay.testing import run_opt_pass, run_infer_type
  import numpy
label_desc: Use image node_id 21 for calling a global function with example usage: test_simplify_clip_cast() and returns: relay, relay, relay, relay, relay, relay, relay, relay, relay, relay