class_docstr: Unit test for triton client.
class_docstr_tok: ["Unit","test","for","triton","client","."]
code: def test_multi_params(self):
      p = (
          pipe.input("nums", "arr")
          .flat_map("nums", "num", lambda x: x)
          .map(("num", "arr"), "ret", lambda x, y: x + y)
          .output("ret")
      )
      MockInferenceServerClient.set_pipeline(p)
      url = "127.0.0.1:8000"
      with triton_client.Client(url) as client:
          in0 = [1, 2, 3]
          in1 = np.random.rand(3, 3)
          res1 = client(in0, in1)
          self.assertEqual(len(res1), 3)
          for index, item in enumerate(res1, 1):
              self.assertTrue((item[0] == (in1 + index)).all())
  
          # test with batch
          res2 = client.batch(
              [[in0, in1], [in0, in1], [in0, in1], [in0, in1]]
          )
          self.assertEqual(len(res2), 4)
          for single in res2:
              for index, item in enumerate(single, 1):
                  self.assertTrue((item[0] == (in1 + index)).all())
  
          # safe batch
          res2 = client.batch(
              [[in0, in1], [in0, in1], [in0, in1], ["err"]],
              batch_size=2,
              safe=True,
          )
          self.assertIsNone(res2[-1])
          self.assertIsNone(res2[-2])
          self.assertEqual(len(res2), 4)
          for single in res2[:2]:
              for index, item in enumerate(single, 1):
                  self.assertTrue((item[0] == (in1 + index)).all())
  
          # unsafe batch
          with self.assertRaises(Exception):
              _ = client.batch(
                  [
                      [in0, in1],
                      [in0, in1],
                      [in0, in1],
                      [in0, in1],
                      ["err"],
                  ],
                  batch_size=2,
                  safe=False,
              )
  
imports: from typing import List
  import unittest
  from unittest import mock
  from pathlib import Path
  from tempfile import TemporaryDirectory
  import numpy
  from towhee import pipe
  from towhee.serve.triton import triton_client
  from towhee.utils.thirdparty.dill_util import dill
  import towhee.serve.triton.bls.pipeline_model
  from towhee.serve.triton.bls.python_backend_wrapper import pb_utils
  from towhee.utils.serializer import from_json
label_desc: Use image node_id 3 for calling the TestTritonClient obj's underlying member method code with example usage: obj.test_multi_params() without return types