code: def compute_output_spec(fn, *args, **kwargs):
      with StatelessScope():
  
          def has_none_shape(x):
              if isinstance(x, KerasTensor):
                  return None in x.shape
              return False
  
          none_in_shape = any(
              map(has_none_shape, tree.flatten((args, kwargs)))
          )
  
          def convert_keras_tensor_to_numpy(x, fill_value=None):
              if isinstance(x, KerasTensor):
                  shape = list(x.shape)
                  if fill_value:
                      for i, e in enumerate(shape):
                          if e is None:
                              shape[i] = fill_value
                  return np.empty(
                      shape=shape,
                      dtype=x.dtype,
                  )
              return x
  
          args_1, kwargs_1 = tree.map_structure(
              lambda x: convert_keras_tensor_to_numpy(x, fill_value=83),
              (args, kwargs),
          )
          outputs_1 = fn(*args_1, **kwargs_1)
  
          outputs = outputs_1
  
          if none_in_shape:
              args_2, kwargs_2 = tree.map_structure(
                  lambda x: convert_keras_tensor_to_numpy(
                      x, fill_value=89
                  ),
                  (args, kwargs),
              )
              outputs_2 = fn(*args_2, **kwargs_2)
  
              flat_out_1 = tree.flatten(outputs_1)
              flat_out_2 = tree.flatten(outputs_2)
  
              flat_out = []
              for x1, x2 in zip(flat_out_1, flat_out_2):
                  shape = list(x1.shape)
                  for i, e in enumerate(x2.shape):
                      if e != shape[i]:
                          shape[i] = None
                  flat_out.append(
                      KerasTensor(shape, standardize_dtype(x1.dtype))
                  )
              outputs = pack_sequence_as(outputs_1, flat_out)
  
          def convert_numpy_to_keras_tensor(x):
              if is_tensor(x):
                  return KerasTensor(
                      x.shape, standardize_dtype(x.dtype)
                  )
              return x
  
          output_spec = tree.map_structure(
              convert_numpy_to_keras_tensor, outputs
          )
      return output_spec
  
imports: import numpy
  import tree
  from keras.backend.common import KerasVariable
  from keras.backend.common import standardize_dtype
  from keras.backend.common.dtypes import result_type
  from keras.backend.common.keras_tensor import KerasTensor
  from keras.backend.common.stateless_scope import StatelessScope
  from keras.utils.nest import pack_sequence_as
label_desc: Use image node_id 8 for calling a global function with example usage: compute_output_spec(fn) and returns: output_spec, False, x, x, unknown, np, KerasTensor