code: def test_exception_handling_in_dynamic_batch():
      from jina.proto import jina_pb2
  
      class DummyEmbeddingDoc(BaseDoc):
          lf: List[float] = []
  
      class SlowExecutorWithException(Executor):
          @dynamic_batching(preferred_batch_size=3, timeout=1000)
          @requests(on="/foo")
          def foo(
              self, docs: DocList[TextDoc], **kwargs
          ) -> DocList[DummyEmbeddingDoc]:
              ret = DocList[DummyEmbeddingDoc]()
              for doc in docs:
                  if doc.text == "fail":
                      raise Exception("Fail is in the Batch")
                  ret.append(DummyEmbeddingDoc(lf=[0.1, 0.2, 0.3]))
              return ret
  
      depl = Deployment(uses=SlowExecutorWithException)
  
      with depl:
          da = DocList[TextDoc](
              [TextDoc(text=f"good-{i}") for i in range(50)]
          )
          da[4].text = "fail"
          responses = depl.post(
              on="/foo",
              inputs=da,
              request_size=1,
              return_responses=True,
              continue_on_error=True,
              results_in_order=True,
          )
          assert len(responses) == 50  # 1 request per input
          num_failed_requests = 0
          for r in responses:
              if (
                  r.header.status.code
                  == jina_pb2.StatusProto.StatusCode.ERROR
              ):
                  num_failed_requests += 1
  
          assert 1 <= num_failed_requests <= 3
  
imports: import os
  import time
  from typing import Any, AsyncGenerator, AsyncIterator, Dict, Generator, Iterator, List, Optional, Union
  import numpy
  import pytest
  from docarray import BaseDoc, DocList
  from docarray.documents import ImageDoc, TextDoc
  from docarray.documents.legacy import LegacyDocument
  from docarray.typing import AnyTensor, ImageUrl, NdArray
  from jina import Client, Deployment, Executor, Flow, dynamic_batching, requests
  from jina.excepts import RuntimeFailToStart
  from jina.helper import random_port
  import uuid
label_desc: Use image node_id 43 for calling a global function with example usage: test_exception_handling_in_dynamic_batch() and returns: ret