code: def _remove_tensors_from_model(
      model: tflite_schema.ModelT,
      subgraph: tflite_schema.SubGraphT,
      remove_tensors_idxs,
  ):
      """Remove tensors from model."""
      if not remove_tensors_idxs:
          return
      tensors = subgraph.tensors
      operators = subgraph.operators
  
      # An optimized check to validate if "remove_tensors_idxs" (eg: [4,5,6]) is an
      # exact subset, with ordering, of "tensors" indices (eg: [0,1,2,3,4,5,6]).
      if min(remove_tensors_idxs) == len(tensors) - len(
          remove_tensors_idxs
      ):
          del tensors[min(remove_tensors_idxs) :]
      else:
          # Map the old tensor indices to new tensor indices
          d_old_to_new_tensors = {}
          left_shift_by = 0
          for idx in range(len(tensors)):
              if idx in remove_tensors_idxs:
                  left_shift_by += 1
              else:
                  d_old_to_new_tensors[idx] = idx - left_shift_by
  
          # Update tensor indices referenced throughout the model
          def update_tensors(tensor_idxs):
              for i, ti in enumerate(tensor_idxs):
                  tensor_idxs[i] = d_old_to_new_tensors.get(ti, -1)
  
          update_tensors(subgraph.inputs)
          update_tensors(subgraph.outputs)
          for op in operators:
              update_tensors(op.inputs)
              update_tensors(op.outputs)
          if model.signatureDefs:
              signature_def = model.signatureDefs[0]
              _update_signature_def_tensors(
                  signature_def.inputs, d_old_to_new_tensors
              )
              _update_signature_def_tensors(
                  signature_def.outputs, d_old_to_new_tensors
              )
          # Delete the tensors
          for idx in sorted(remove_tensors_idxs, reverse=True):
              tensors.pop(idx)
  
file_path: compute-engine/larq_compute_engine/mlir/python/util.py
imports: import copy
  import flatbuffers
  import tensorflow
  from larq_compute_engine.mlir.python import tflite_schema
label_desc: Use image node_id 5 for calling a global function with example usage: _remove_tensors_from_model(model, subgraph, remove_tensors_idxs) without return types