code: def _edit_distance_update(
      preds: Union[str, Sequence[str]],
      target: Union[str, Sequence[str]],
      substitution_cost: int = 1,
  ) -> Tensor:
      if isinstance(preds, str):
          preds = [preds]
      if isinstance(target, str):
          target = [target]
      if not all(isinstance(x, str) for x in preds):
          raise ValueError(
              f"Expected all values in argument `preds` to be string type, but got {preds}"
          )
      if not all(isinstance(x, str) for x in target):
          raise ValueError(
              f"Expected all values in argument `target` to be string type, but got {target}"
          )
      if len(preds) != len(target):
          raise ValueError(
              f"Expected argument `preds` and `target` to have same length, but got {len(preds)} and {len(target)}"
          )
  
      distance = [
          _LE_distance(t, op_substitute=substitution_cost)(p)[0] for p, t in zip(preds, target)  # type: ignore[arg-type]
      ]
      return torch.tensor(distance, dtype=torch.int)
  
imports: from typing import Literal, Optional, Sequence, Union
  import torch
  from torch import Tensor
  from torchmetrics.functional.text.helper import _LevenshteinEditDistance
label_desc: Use image node_id 1 for calling a global function with example usage: _edit_distance_update(preds, target, substitution_cost) and returns: torch