code: def compute_output_dims_lengths(
      array_name: str, loop_orders, sub
  ) -> str:
      """Create c_code to compute the output dimensions of an Elemwise operation.
  
      The code returned by this function populates the array `array_name`, but does not
      initialize it.
  
      Note: We could specialize C code even further with the known static output shapes
      """
      dims_c_code = ""
      for i, candidates in enumerate(zip(*loop_orders)):
          # Borrow the length of the first non-broadcastable input dimension
          for j, candidate in enumerate(candidates):
              if candidate != "x":
                  var = sub[f"lv{int(j)}"]
                  dims_c_code += (
                      f"{array_name}[{i}] = {var}_n{candidate};\n"
                  )
                  break
          # If none is non-broadcastable, the output dimension has a length of 1
          else:  # no-break
              dims_c_code += f"{array_name}[{i}] = 1;\n"
  
      return dims_c_code
  
file_path: pytensor/pytensor/tensor/elemwise_cgen.py
imports: from pytensor.configdefaults import config
label_desc: Use image node_id 3 for calling a global function with example usage: compute_output_dims_lengths(array_name, loop_orders, sub) and returns: dims_c_code