prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  deprecated eval_fn still used in examples
  ### Describe the bug
  
  While running the `embedded_devices` example, an issue is faced due to the use of `eval_fn` keyword which was deprecated after Flower 1.0.0 and has now been changed to `evaluate_fn`
  
  ### Steps/Code to Reproduce
  
  Setup the server as mentioned in the `examples/embedded_devices` readme
  
  ### Expected Results
  
  The server should start without any error
  
  ### Actual Results
  
  The following error is encountered:
  ```
  File "/embedded_devices/server.py", line 109, in main
       strategy = fl.server.strategy.FedAvg(
  TypeError: FedAvg.__init__() got an unexpected keyword argument 'eval_fn'
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/embedded_devices/server.py`
  Content:
  ```
  1 # Copyright 2020 Adap GmbH. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 # ==============================================================================
  15 """Minimal example on how to start a simple Flower server."""
  16 
  17 
  18 import argparse
  19 from collections import OrderedDict
  20 from typing import Callable, Dict, Optional, Tuple
  21 
  22 import flwr as fl
  23 import numpy as np
  24 import torch
  25 import torchvision
  26 
  27 import utils
  28 
  29 # pylint: disable=no-member
  30 DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
  31 # pylint: enable=no-member
  32 
  33 parser = argparse.ArgumentParser(description="Flower")
  34 parser.add_argument(
  35     "--server_address",
  36     type=str,
  37     required=True,
  38     help=f"gRPC server address",
  39 )
  40 parser.add_argument(
  41     "--rounds",
  42     type=int,
  43     default=1,
  44     help="Number of rounds of federated learning (default: 1)",
  45 )
  46 parser.add_argument(
  47     "--sample_fraction",
  48     type=float,
  49     default=1.0,
  50     help="Fraction of available clients used for fit/evaluate (default: 1.0)",
  51 )
  52 parser.add_argument(
  53     "--min_sample_size",
  54     type=int,
  55     default=2,
  56     help="Minimum number of clients used for fit/evaluate (default: 2)",
  57 )
  58 parser.add_argument(
  59     "--min_num_clients",
  60     type=int,
  61     default=2,
  62     help="Minimum number of available clients required for sampling (default: 2)",
  63 )
  64 parser.add_argument(
  65     "--log_host",
  66     type=str,
  67     help="Logserver address (no default)",
  68 )
  69 parser.add_argument(
  70     "--model",
  71     type=str,
  72     default="ResNet18",
  73     choices=["Net", "ResNet18"],
  74     help="model to train",
  75 )
  76 parser.add_argument(
  77     "--batch_size",
  78     type=int,
  79     default=32,
  80     help="training batch size",
  81 )
  82 parser.add_argument(
  83     "--num_workers",
  84     type=int,
  85     default=4,
  86     help="number of workers for dataset reading",
  87 )
  88 parser.add_argument("--pin_memory", action="store_true")
  89 args = parser.parse_args()
  90 
  91 
  92 def main() -> None:
  93     """Start server and train five rounds."""
  94 
  95     print(args)
  96 
  97     assert (
  98         args.min_sample_size <= args.min_num_clients
  99     ), f"Num_clients shouldn't be lower than min_sample_size"
  100 
  101     # Configure logger
  102     fl.common.logger.configure("server", host=args.log_host)
  103 
  104     # Load evaluation data
  105     _, testset = utils.load_cifar(download=True)
  106 
  107     # Create client_manager, strategy, and server
  108     client_manager = fl.server.SimpleClientManager()
  109     strategy = fl.server.strategy.FedAvg(
  110         fraction_fit=args.sample_fraction,
  111         min_fit_clients=args.min_sample_size,
  112         min_available_clients=args.min_num_clients,
  113         eval_fn=get_eval_fn(testset),
  114         on_fit_config_fn=fit_config,
  115     )
  116     server = fl.server.Server(client_manager=client_manager, strategy=strategy)
  117 
  118     # Run server
  119     fl.server.start_server(
  120         server_address=args.server_address,
  121         server=server,
  122         config=fl.server.ServerConfig(num_rounds=args.rounds),
  123     )
  124 
  125 
  126 def fit_config(server_round: int) -> Dict[str, fl.common.Scalar]:
  127     """Return a configuration with static batch size and (local) epochs."""
  128     config = {
  129         "epoch_global": str(server_round),
  130         "epochs": str(1),
  131         "batch_size": str(args.batch_size),
  132         "num_workers": str(args.num_workers),
  133         "pin_memory": str(args.pin_memory),
  134     }
  135     return config
  136 
  137 
  138 def set_weights(model: torch.nn.ModuleList, weights: fl.common.NDArrays) -> None:
  139     """Set model weights from a list of NumPy ndarrays."""
  140     state_dict = OrderedDict(
  141         {
  142             k: torch.tensor(np.atleast_1d(v))
  143             for k, v in zip(model.state_dict().keys(), weights)
  144         }
  145     )
  146     model.load_state_dict(state_dict, strict=True)
  147 
  148 
  149 def get_eval_fn(
  150     testset: torchvision.datasets.CIFAR10,
  151 ) -> Callable[[fl.common.NDArrays], Optional[Tuple[float, float]]]:
  152     """Return an evaluation function for centralized evaluation."""
  153 
  154     def evaluate(weights: fl.common.NDArrays) -> Optional[Tuple[float, float]]:
  155         """Use the entire CIFAR-10 test set for evaluation."""
  156 
  157         model = utils.load_model(args.model)
  158         set_weights(model, weights)
  159         model.to(DEVICE)
  160 
  161         testloader = torch.utils.data.DataLoader(testset, batch_size=32, shuffle=False)
  162         loss, accuracy = utils.test(model, testloader, device=DEVICE)
  163         return loss, {"accuracy": accuracy}
  164 
  165     return evaluate
  166 
  167 
  168 if __name__ == "__main__":
  169     main()
  170
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/embedded_devices/server.py b/examples/embedded_devices/server.py
  --- a/examples/embedded_devices/server.py
  +++ b/examples/embedded_devices/server.py
  @@ -110,7 +110,7 @@
           fraction_fit=args.sample_fraction,
           min_fit_clients=args.min_sample_size,
           min_available_clients=args.min_num_clients,
  -        eval_fn=get_eval_fn(testset),
  +        evaluate_fn=get_eval_fn(testset),
           on_fit_config_fn=fit_config,
       )
       server = fl.server.Server(client_manager=client_manager, strategy=strategy)
  
verification_info: {"golden_diff": "diff --git a/examples/embedded_devices/server.py b/examples/embedded_devices/server.py\n--- a/examples/embedded_devices/server.py\n+++ b/examples/embedded_devices/server.py\n@@ -110,7 +110,7 @@\n         fraction_fit=args.sample_fraction,\n         min_fit_clients=args.min_sample_size,\n         min_available_clients=args.min_num_clients,\n-        eval_fn=get_eval_fn(testset),\n+        evaluate_fn=get_eval_fn(testset),\n         on_fit_config_fn=fit_config,\n     )\n     server = fl.server.Server(client_manager=client_manager, strategy=strategy)\n", "issue": "deprecated eval_fn still used in examples\n### Describe the bug\n\nWhile running the `embedded_devices` example, an issue is faced due to the use of `eval_fn` keyword which was deprecated after Flower 1.0.0 and has now been changed to `evaluate_fn`\n\n### Steps/Code to Reproduce\n\nSetup the server as mentioned in the `examples/embedded_devices` readme\n\n### Expected Results\n\nThe server should start without any error\n\n### Actual Results\n\nThe following error is encountered:\r\n```\r\nFile \"/embedded_devices/server.py\", line 109, in main\r\n     strategy = fl.server.strategy.FedAvg(\r\nTypeError: FedAvg.__init__() got an unexpected keyword argument 'eval_fn'\r\n```\n", "before_files": [{"content": "# Copyright 2020 Adap GmbH. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Minimal example on how to start a simple Flower server.\"\"\"\n\n\nimport argparse\nfrom collections import OrderedDict\nfrom typing import Callable, Dict, Optional, Tuple\n\nimport flwr as fl\nimport numpy as np\nimport torch\nimport torchvision\n\nimport utils\n\n# pylint: disable=no-member\nDEVICE = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n# pylint: enable=no-member\n\nparser = argparse.ArgumentParser(description=\"Flower\")\nparser.add_argument(\n    \"--server_address\",\n    type=str,\n    required=True,\n    help=f\"gRPC server address\",\n)\nparser.add_argument(\n    \"--rounds\",\n    type=int,\n    default=1,\n    help=\"Number of rounds of federated learning (default: 1)\",\n)\nparser.add_argument(\n    \"--sample_fraction\",\n    type=float,\n    default=1.0,\n    help=\"Fraction of available clients used for fit/evaluate (default: 1.0)\",\n)\nparser.add_argument(\n    \"--min_sample_size\",\n    type=int,\n    default=2,\n    help=\"Minimum number of clients used for fit/evaluate (default: 2)\",\n)\nparser.add_argument(\n    \"--min_num_clients\",\n    type=int,\n    default=2,\n    help=\"Minimum number of available clients required for sampling (default: 2)\",\n)\nparser.add_argument(\n    \"--log_host\",\n    type=str,\n    help=\"Logserver address (no default)\",\n)\nparser.add_argument(\n    \"--model\",\n    type=str,\n    default=\"ResNet18\",\n    choices=[\"Net\", \"ResNet18\"],\n    help=\"model to train\",\n)\nparser.add_argument(\n    \"--batch_size\",\n    type=int,\n    default=32,\n    help=\"training batch size\",\n)\nparser.add_argument(\n    \"--num_workers\",\n    type=int,\n    default=4,\n    help=\"number of workers for dataset reading\",\n)\nparser.add_argument(\"--pin_memory\", action=\"store_true\")\nargs = parser.parse_args()\n\n\ndef main() -> None:\n    \"\"\"Start server and train five rounds.\"\"\"\n\n    print(args)\n\n    assert (\n        args.min_sample_size <= args.min_num_clients\n    ), f\"Num_clients shouldn't be lower than min_sample_size\"\n\n    # Configure logger\n    fl.common.logger.configure(\"server\", host=args.log_host)\n\n    # Load evaluation data\n    _, testset = utils.load_cifar(download=True)\n\n    # Create client_manager, strategy, and server\n    client_manager = fl.server.SimpleClientManager()\n    strategy = fl.server.strategy.FedAvg(\n        fraction_fit=args.sample_fraction,\n        min_fit_clients=args.min_sample_size,\n        min_available_clients=args.min_num_clients,\n        eval_fn=get_eval_fn(testset),\n        on_fit_config_fn=fit_config,\n    )\n    server = fl.server.Server(client_manager=client_manager, strategy=strategy)\n\n    # Run server\n    fl.server.start_server(\n        server_address=args.server_address,\n        server=server,\n        config=fl.server.ServerConfig(num_rounds=args.rounds),\n    )\n\n\ndef fit_config(server_round: int) -> Dict[str, fl.common.Scalar]:\n    \"\"\"Return a configuration with static batch size and (local) epochs.\"\"\"\n    config = {\n        \"epoch_global\": str(server_round),\n        \"epochs\": str(1),\n        \"batch_size\": str(args.batch_size),\n        \"num_workers\": str(args.num_workers),\n        \"pin_memory\": str(args.pin_memory),\n    }\n    return config\n\n\ndef set_weights(model: torch.nn.ModuleList, weights: fl.common.NDArrays) -> None:\n    \"\"\"Set model weights from a list of NumPy ndarrays.\"\"\"\n    state_dict = OrderedDict(\n        {\n            k: torch.tensor(np.atleast_1d(v))\n            for k, v in zip(model.state_dict().keys(), weights)\n        }\n    )\n    model.load_state_dict(state_dict, strict=True)\n\n\ndef get_eval_fn(\n    testset: torchvision.datasets.CIFAR10,\n) -> Callable[[fl.common.NDArrays], Optional[Tuple[float, float]]]:\n    \"\"\"Return an evaluation function for centralized evaluation.\"\"\"\n\n    def evaluate(weights: fl.common.NDArrays) -> Optional[Tuple[float, float]]:\n        \"\"\"Use the entire CIFAR-10 test set for evaluation.\"\"\"\n\n        model = utils.load_model(args.model)\n        set_weights(model, weights)\n        model.to(DEVICE)\n\n        testloader = torch.utils.data.DataLoader(testset, batch_size=32, shuffle=False)\n        loss, accuracy = utils.test(model, testloader, device=DEVICE)\n        return loss, {\"accuracy\": accuracy}\n\n    return evaluate\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "examples/embedded_devices/server.py"}], "after_files": [{"content": "# Copyright 2020 Adap GmbH. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Minimal example on how to start a simple Flower server.\"\"\"\n\n\nimport argparse\nfrom collections import OrderedDict\nfrom typing import Callable, Dict, Optional, Tuple\n\nimport flwr as fl\nimport numpy as np\nimport torch\nimport torchvision\n\nimport utils\n\n# pylint: disable=no-member\nDEVICE = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n# pylint: enable=no-member\n\nparser = argparse.ArgumentParser(description=\"Flower\")\nparser.add_argument(\n    \"--server_address\",\n    type=str,\n    required=True,\n    help=f\"gRPC server address\",\n)\nparser.add_argument(\n    \"--rounds\",\n    type=int,\n    default=1,\n    help=\"Number of rounds of federated learning (default: 1)\",\n)\nparser.add_argument(\n    \"--sample_fraction\",\n    type=float,\n    default=1.0,\n    help=\"Fraction of available clients used for fit/evaluate (default: 1.0)\",\n)\nparser.add_argument(\n    \"--min_sample_size\",\n    type=int,\n    default=2,\n    help=\"Minimum number of clients used for fit/evaluate (default: 2)\",\n)\nparser.add_argument(\n    \"--min_num_clients\",\n    type=int,\n    default=2,\n    help=\"Minimum number of available clients required for sampling (default: 2)\",\n)\nparser.add_argument(\n    \"--log_host\",\n    type=str,\n    help=\"Logserver address (no default)\",\n)\nparser.add_argument(\n    \"--model\",\n    type=str,\n    default=\"ResNet18\",\n    choices=[\"Net\", \"ResNet18\"],\n    help=\"model to train\",\n)\nparser.add_argument(\n    \"--batch_size\",\n    type=int,\n    default=32,\n    help=\"training batch size\",\n)\nparser.add_argument(\n    \"--num_workers\",\n    type=int,\n    default=4,\n    help=\"number of workers for dataset reading\",\n)\nparser.add_argument(\"--pin_memory\", action=\"store_true\")\nargs = parser.parse_args()\n\n\ndef main() -> None:\n    \"\"\"Start server and train five rounds.\"\"\"\n\n    print(args)\n\n    assert (\n        args.min_sample_size <= args.min_num_clients\n    ), f\"Num_clients shouldn't be lower than min_sample_size\"\n\n    # Configure logger\n    fl.common.logger.configure(\"server\", host=args.log_host)\n\n    # Load evaluation data\n    _, testset = utils.load_cifar(download=True)\n\n    # Create client_manager, strategy, and server\n    client_manager = fl.server.SimpleClientManager()\n    strategy = fl.server.strategy.FedAvg(\n        fraction_fit=args.sample_fraction,\n        min_fit_clients=args.min_sample_size,\n        min_available_clients=args.min_num_clients,\n        evaluate_fn=get_eval_fn(testset),\n        on_fit_config_fn=fit_config,\n    )\n    server = fl.server.Server(client_manager=client_manager, strategy=strategy)\n\n    # Run server\n    fl.server.start_server(\n        server_address=args.server_address,\n        server=server,\n        config=fl.server.ServerConfig(num_rounds=args.rounds),\n    )\n\n\ndef fit_config(server_round: int) -> Dict[str, fl.common.Scalar]:\n    \"\"\"Return a configuration with static batch size and (local) epochs.\"\"\"\n    config = {\n        \"epoch_global\": str(server_round),\n        \"epochs\": str(1),\n        \"batch_size\": str(args.batch_size),\n        \"num_workers\": str(args.num_workers),\n        \"pin_memory\": str(args.pin_memory),\n    }\n    return config\n\n\ndef set_weights(model: torch.nn.ModuleList, weights: fl.common.NDArrays) -> None:\n    \"\"\"Set model weights from a list of NumPy ndarrays.\"\"\"\n    state_dict = OrderedDict(\n        {\n            k: torch.tensor(np.atleast_1d(v))\n            for k, v in zip(model.state_dict().keys(), weights)\n        }\n    )\n    model.load_state_dict(state_dict, strict=True)\n\n\ndef get_eval_fn(\n    testset: torchvision.datasets.CIFAR10,\n) -> Callable[[fl.common.NDArrays], Optional[Tuple[float, float]]]:\n    \"\"\"Return an evaluation function for centralized evaluation.\"\"\"\n\n    def evaluate(weights: fl.common.NDArrays) -> Optional[Tuple[float, float]]:\n        \"\"\"Use the entire CIFAR-10 test set for evaluation.\"\"\"\n\n        model = utils.load_model(args.model)\n        set_weights(model, weights)\n        model.to(DEVICE)\n\n        testloader = torch.utils.data.DataLoader(testset, batch_size=32, shuffle=False)\n        loss, accuracy = utils.test(model, testloader, device=DEVICE)\n        return loss, {\"accuracy\": accuracy}\n\n    return evaluate\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "examples/embedded_devices/server.py"}]}