code: def test_endpoint_errors_on_wrong_key_name(
      lightning_squeezenet1_1_obj,
  ):
      from tests.core.serve.models import (
          ClassificationInferenceComposable,
      )
  
      comp1 = ClassificationInferenceComposable(
          lightning_squeezenet1_1_obj
      )
  
      # input key does not exist
      with pytest.raises(AttributeError):
          _ = Endpoint(
              route="/predict",
              inputs={
                  "label_1": comp1.inputs.img,
                  "tag_1": comp1.inputs.DOESNOTEXIST,
              },
              outputs={
                  "prediction": comp1.outputs.predicted_tag,
                  "cropped": comp1.outputs.cropped_img,
              },
          )
  
      # output key does not exist
      with pytest.raises(AttributeError):
          _ = Endpoint(
              route="/predict",
              inputs={
                  "label_1": comp1.inputs.img,
                  "tag_1": comp1.inputs.tag,
              },
              outputs={
                  "prediction": comp1.outputs.predicted_tag,
                  "cropped": comp1.outputs.DOESNOTEXIST,
              },
          )
  
      # output key does not exist
      ep = Endpoint(
          route="/predict",
          inputs={
              "label_1": comp1.inputs.img,
              "tag_1": comp1.inputs.tag,
          },
          outputs={
              "prediction": comp1.outputs.predicted_tag,
              "cropped": "callnum_1.outputs.DOESNOTEXIST",
          },
      )
      with pytest.raises(AttributeError):
          _ = Composition(comp1=comp1, predict_ep=ep)
  
      # input function does not exist
      ep = Endpoint(
          route="/predict",
          inputs={
              "label_1": comp1.inputs.img,
              "tag_1": "DOESNOTEXIST.inputs.tag",
          },
          outputs={
              "prediction": comp1.outputs.predicted_tag,
              "cropped": comp1.outputs.cropped_img,
          },
      )
      with pytest.raises(AttributeError):
          _ = Composition(comp1=comp1, predict_ep=ep)
  
      # output function does not exist
      ep = Endpoint(
          route="/predict",
          inputs={
              "label_1": comp1.inputs.img,
              "tag_1": comp1.inputs.tag,
          },
          outputs={
              "prediction": comp1.outputs.predicted_tag,
              "cropped": "DOESNOTEXIST.outputs.cropped_img",
          },
      )
      with pytest.raises(AttributeError):
          _ = Composition(comp1=comp1, predict_ep=ep)
  
file_path: lightning-flash/tests/core/serve/test_composition.py
imports: import base64
  from dataclasses import asdict
  import pytest
  from flash.core.serve import Composition, Endpoint
  from flash.core.utilities.imports import _FASTAPI_AVAILABLE, _TOPIC_SERVE_AVAILABLE
label_desc: Use image node_id 2 for calling a global function with example usage: test_endpoint_errors_on_wrong_key_name(lightning_squeezenet1_1_obj) without return types