code: def validate(self):
      assert not (
          self.is_singleton_doc and self.is_batch_docs
      ), f"Cannot specify both the `doc` and the `docs` paramater for {self.fn.__name__}"
      assert not (
          self.is_generator and self.is_batch_docs
      ), f"Cannot specify the `docs` parameter if the endpoint {self.fn.__name__} is a generator"
      if docarray_v2:
          from docarray import BaseDoc, DocList
  
          if not self.is_generator:
              if self.is_batch_docs and (
                  not issubclass(self.request_schema, DocList)
                  or not issubclass(self.response_schema, DocList)
              ):
                  faulty_schema = (
                      "request_schema"
                      if not issubclass(self.request_schema, DocList)
                      else "response_schema"
                  )
                  raise Exception(
                      f"The {faulty_schema} schema for {self.fn.__name__}: {self.request_schema} is not a DocList. Please make sure that your endpoint used DocList for request and response schema"
                  )
              if self.is_singleton_doc and (
                  not issubclass(self.request_schema, BaseDoc)
                  or not issubclass(self.response_schema, BaseDoc)
              ):
                  faulty_schema = (
                      "request_schema"
                      if not issubclass(self.request_schema, BaseDoc)
                      else "response_schema"
                  )
                  raise Exception(
                      f"The {faulty_schema} schema for {self.fn.__name__}: {self.request_schema} is not a BaseDoc. Please make sure that your endpoint used BaseDoc for request and response schema"
                  )
          else:
              if not issubclass(self.request_schema, BaseDoc) or not (
                  issubclass(self.response_schema, BaseDoc)
                  or issubclass(self.response_schema, BaseDoc)
              ):  # response_schema may be a DocList because by default we use LegacyDocument, and for generators we ignore response
                  faulty_schema = (
                      "request_schema"
                      if not issubclass(self.request_schema, BaseDoc)
                      else "response_schema"
                  )
                  raise Exception(
                      f"The {faulty_schema} schema for {self.fn.__name__}: {self.request_schema} is not a BaseDoc. Please make sure that your streaming endpoints used BaseDoc for request and response schema"
                  )
  
imports: from __future__ import annotations
  import asyncio
  import contextlib
  import copy
  import functools
  import inspect
  import multiprocessing
  import os
  import threading
  import warnings
  from collections.abc import AsyncGenerator, AsyncIterator, Generator, Iterator
  from types import SimpleNamespace
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, NamedTuple, Optional, Type, TypeVar, Union, _GenericAlias, overload
  from jina._docarray import DocumentArray, docarray_v2
  from jina.constants import __args_executor_init__, __cache_path__, __default_endpoint__
  from jina.enums import BetterEnum, ProviderType
  from jina.helper import ArgNamespace, T, get_or_reuse_loop, iscoroutinefunction, typename
  from jina.importer import ImportExtensions
  from jina.jaml import JAML, JAMLCompatible, env_var_regex, internal_var_regex
  from jina.logging.logger import JinaLogger
  from jina.serve.executors.decorators import _init_requests_by_class, avoid_concurrent_lock_cls
  from jina.serve.executors.metas import get_executor_taboo
  from jina.serve.helper import _get_workspace_from_name_and_shards, store_init_kwargs, wrap_func
  from jina.serve.instrumentation import MetricsTimer
label_desc: Use image node_id 1 for calling the _FunctionWithSchema obj's underlying member method code with example usage: obj.validate() without return types