code: def extern(
      shape,
      inputs,
      fcompute,
      name="extern",
      dtype=None,
      in_buffers=None,
      out_buffers=None,
      tag="",
      attrs=None,
  ):
      """Compute several tensors via an extern function.
  
      Parameters
      ----------
      shape: tuple or list of tuples.
          The shape of the outputs.
  
      inputs: list of Tensor
          The inputs
  
      fcompute: lambda function of inputs, outputs-> stmt
          Specifies the IR statement to do the computation.
          See the following note for function signature of fcompute
  
          .. note::
               **Parameters**
  
               - **ins** (list of :any:`tvm.tir.Buffer`) - Placeholder for each inputs
               - **outs** (list of :any:`tvm.tir.Buffer`) - Placeholder for each outputs
  
               **Returns**
  
               - **stmt** (:any:`tvm.tir.Stmt`) - The statement that carries out array computation.
  
      name: str, optional
          The name hint of the tensor
  
      dtype: str or list of str, optional
          The data types of outputs,
          by default dtype will be same as inputs.
  
      in_buffers: tvm.tir.Buffer or list of tvm.tir.Buffer, optional
          Input buffers.
  
      out_buffers: tvm.tir.Buffer or list of tvm.tir.Buffer, optional
          Output buffers.
  
  
      tag: str, optional
          Additonal tag information about the compute.
  
      attrs: dict, optional
          The additional auxiliary attributes about the compute.
  
      Returns
      -------
      tensor: Tensor or list of Tensors
          The created tensor or tuple of tensors contains multiple outputs.
  
      Example
      -------
      In the code below, C is generated by calling external PackedFunc
      `tvm.contrib.cblas.matmul`
  
      .. code-block:: python
  
          A = te.placeholder((n, l), name="A")
          B = te.placeholder((l, m), name="B")
          C = te.extern((n, m), [A, B],
                         lambda ins, outs: tvm.tir.call_packed(
                            "tvm.contrib.cblas.matmul",
                              ins[0], ins[1], outs[0], 0, 0), name="C")
      """
      if _tag.TagScope.get_current() is not None:
          if tag != "":
              raise ValueError("nested tag is not allowed for now")
          tag = _tag.TagScope.get_current().tag
      shape = (
          (shape,)
          if isinstance(shape, (tvm.tir.PrimExpr, _Integral))
          else shape
      )
      if shape == () or isinstance(
          shape[0], (tvm.tir.PrimExpr, _Integral)
      ):
          shape = [shape]
      if in_buffers is not None:
          in_buffers = (
              [in_buffers]
              if not isinstance(in_buffers, list)
              else in_buffers
          )
          if len(inputs) != len(in_buffers):
              raise RuntimeError(
                  "Number of inputs and in_buffers mismatch: %d vs %d."
                  % (len(inputs), len(in_buffers))
              )
      if out_buffers is not None:
          out_buffers = (
              [out_buffers]
              if not isinstance(out_buffers, list)
              else out_buffers
          )
          if len(shape) != len(out_buffers):
              raise RuntimeError(
                  "Number of outputs and out_buffers mismatch: %d vs %d."
                  % (len(shape), len(out_buffers))
              )
      input_placeholders = in_buffers or []
      output_placeholders = out_buffers or []
      types = set()
      for t in inputs:
          if not isinstance(t, _tensor.Tensor):
              raise ValueError("expect inputs to be tensor")
          if in_buffers is None:
              input_placeholders.append(
                  tvm.tir.decl_buffer(
                      t.shape,
                      t.dtype,
                      t.op.name,
                      elem_offset=tvm.tir.Var("elem_offset", "int32"),
                  )
              )
          types.add(t.dtype)
  
      if dtype is None:
          if len(types) != 1:
              raise ValueError(
                  "Cannot infer output type, please provide dtype argument"
              )
          infered_type = types.pop()
          dtype = [infered_type for _ in shape]
      if isinstance(dtype, str):
          dtype = [dtype]
  
      if out_buffers is None:
          for shp, dt in zip(shape, dtype):
              output_placeholders.append(
                  tvm.tir.decl_buffer(
                      shp,
                      dt,
                      name,
                      elem_offset=tvm.tir.Var("elem_offset", "int32"),
                  )
              )
      body = fcompute(input_placeholders, output_placeholders)
      if isinstance(body, tvm.tir.PrimExpr):
          body = tvm.tir.Evaluate(body)
      if not isinstance(body, tvm.tir.Stmt):
          raise ValueError(
              f"Function '{fcompute.__name__}' should return PrimExpr or Stmt, but it returned "
              f"'{type(body)}'"
          )
  
      op = _ffi_api.ExternOp(
          name,
          tag,
          attrs,
          inputs,
          input_placeholders,
          output_placeholders,
          body,
      )
      res = [op.output(i) for i in range(len(output_placeholders))]
      return res[0] if len(res) == 1 else res
  
imports: import inspect
  from numbers import Integral
  from typing import List, Optional
  import tvm._ffi
  import tvm.arith._ffi_api
  import tvm.tir
  import tvm.tir._ffi_api
  from tvm._ffi.base import string_types
  from tvm.ir import Array
  from tvm.runtime import convert
  from .None import _ffi_api
  from .None import tag
  from .None import tensor
label_desc: Use image node_id 4 for calling a global function with example usage: extern(shape, inputs, fcompute, name, dtype, in_buffers, out_buffers, tag, attrs) and returns: unknown