code: def infer_fn_index(app: App, api_name: str, body: PredictBody) -> int:
      if body.fn_index is None:
          for i, fn in enumerate(app.get_blocks().dependencies):
              if fn["api_name"] == api_name:
                  return i
  
          raise FnIndexInferError(
              f"Could not infer fn_index for api_name {api_name}."
          )
      else:
          return body.fn_index
  
imports: from __future__ import annotations
  import hashlib
  import json
  from collections import deque
  from dataclasses import dataclass
  from tempfile import NamedTemporaryFile, _TemporaryFileWrapper
  from typing import TYPE_CHECKING, AsyncGenerator, BinaryIO, List, Optional, Tuple, Union
  import fastapi
  import httpx
  import multipart
  from gradio_client.documentation import document, set_documentation_group
  from multipart.multipart import parse_options_header
  from starlette.datastructures import FormData, Headers, UploadFile
  from starlette.formparsers import MultiPartException, MultipartPart
  from gradio import utils
  from gradio.data_classes import PredictBody
  from gradio.exceptions import Error
  from gradio.helpers import EventData
  from gradio.state_holder import SessionState
label_desc: Use image node_id 1 for calling a global function with example usage: infer_fn_index(app, api_name, body) and returns: body, i