code: def remove_env_arg(cmd_args: list[str]) -> list[str]:
      """
      Removes `--env <env_name>` or `--env=<env_name>` from sys.argv
      """
      indices_to_remove: list[int] = []
      for i, arg in enumerate(cmd_args):
          # regex matching click.option
          if re.match(r"^--env=?.*", arg):
              indices_to_remove.append(i)
              if "=" not in arg:
                  indices_to_remove.append(i + 1)
  
      new_cmd_args: list[str] = []
      for i, arg in enumerate(cmd_args):
          if i not in indices_to_remove:
              new_cmd_args.append(arg)
      return new_cmd_args
  
imports: from __future__ import annotations
  import functools
  import logging
  import os
  import re
  import sys
  import typing
  from shutil import which
  import click
  import fs
  from simple_di import Provide
  from simple_di import inject
  from bentoml._internal.bento.bento import BENTO_YAML_FILENAME
  from bentoml._internal.bento.bento import DEFAULT_BENTO_BUILD_FILE
  from bentoml._internal.bento.bento import Bento
  from bentoml._internal.bento.bento import BentoStore
  from bentoml._internal.configuration import get_debug_mode
  from bentoml._internal.configuration.containers import BentoMLContainer
  from bentoml._internal.env_manager import EnvManager
  from bentoml._internal.env_manager.envs import Environment
  from bentoml.exceptions import BentoMLException
  from bentoml.exceptions import NotFound
label_desc: Use image node_id 1 for calling a global function with example usage: remove_env_arg(cmd_args) and returns: new_cmd_args