We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't send the values of int to device
My training data looks like:

src_image, target_image, src_camera, target_camera, src_camera_idx, target_camera_idx

Where src_camera_idx, target_camera_idx are integers

When I try to apply accelerate I get the following error:
TypeError: Can't send the values of type <class 'int'> to device cuda:0, only of nested list/tuple/dicts of tensors or objects having a `to` method.

We don't need to send the integers to the device. Perhaps instead of raising an error here, you can simply skip the items that cannot be moved to device? Or at least give me the option to skip them if I know my data has such objects.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/accelerate/utils.py`
Content:
```
1 # Copyright 2021 The HuggingFace Team. 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 import random
16 from enum import Enum
17 from typing import List, Optional, Union
18 
19 import numpy as np
20 import torch
21 
22 from .state import AcceleratorState, DistributedType, is_tpu_available
23 
24 
25 if is_tpu_available():
26     import torch_xla.core.xla_model as xm
27 
28 
29 class RNGType(Enum):
30     TORCH = "torch"
31     CUDA = "cuda"
32     XLA = "xla"
33     GENERATOR = "generator"
34 
35 
36 def set_seed(seed: int):
37     """
38     Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch``.
39 
40     Args:
41         seed (:obj:`int`): The seed to set.
42     """
43     random.seed(seed)
44     np.random.seed(seed)
45     torch.manual_seed(seed)
46     torch.cuda.manual_seed_all(seed)
47     # ^^ safe to call this function even if cuda is not available
48     if is_tpu_available():
49         xm.set_rng_state(seed)
50 
51 
52 def synchronize_rng_state(rng_type: Optional[RNGType] = None, generator: Optional[torch.Generator] = None):
53     # Get the proper rng state
54     if rng_type == RNGType.TORCH:
55         rng_state = torch.get_rng_state()
56     elif rng_type == RNGType.CUDA:
57         rng_state = torch.cuda.get_rng_state()
58     elif rng_type == RNGType.XLA:
59         assert is_tpu_available(), "Can't synchronize XLA seeds on an environment without TPUs."
60         rng_state = torch.tensor(xm.get_rng_state())
61     elif rng_type == RNGType.GENERATOR:
62         assert generator is not None, "Need a generator to synchronize its seed."
63         rng_state = generator.get_state()
64 
65     # Broadcast the rng state from device 0 to other devices
66     state = AcceleratorState()
67     if state.distributed_type == DistributedType.TPU:
68         rng_state = xm.mesh_reduce("random_seed", rng_state, lambda x: x[0])
69     elif state.distributed_type == DistributedType.MULTI_GPU:
70         rng_state = rng_state.to(state.device)
71         torch.distributed.broadcast(rng_state, 0)
72         rng_state = rng_state.cpu()
73 
74     # Set the broadcast rng state
75     if rng_type == RNGType.TORCH:
76         torch.set_rng_state(rng_state)
77     elif rng_type == RNGType.CUDA:
78         torch.cuda.set_rng_state(rng_state)
79     elif rng_type == RNGType.XLA:
80         xm.set_rng_state(rng_state.item())
81     elif rng_type == RNGType.GENERATOR:
82         generator.set_state(rng_state)
83 
84 
85 def synchronize_rng_states(rng_types: List[Union[str, RNGType]], generator: Optional[torch.Generator] = None):
86     for rng_type in rng_types:
87         synchronize_rng_state(RNGType(rng_type), generator=generator)
88 
89 
90 def send_to_device(tensor, device):
91     """
92     Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.
93 
94     Args:
95         tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):
96             The data to send to a given device.
97         device (:obj:`torch.device`):
98             The device to send the data to
99 
100     Returns:
101         The same data structure as :obj:`tensor` with all tensors sent to the proper device.
102     """
103     if isinstance(tensor, (list, tuple)):
104         return type(tensor)(send_to_device(t, device) for t in tensor)
105     elif isinstance(tensor, dict):
106         return type(tensor)({k: send_to_device(v, device) for k, v in tensor.items()})
107     elif not hasattr(tensor, "to"):
108         raise TypeError(
109             f"Can't send the values of type {type(tensor)} to device {device}, only of nested list/tuple/dicts "
110             "of tensors or objects having a `to` method."
111         )
112     return tensor.to(device)
113 
114 
115 def extract_model_from_parallel(model):
116     """
117     Extract a model from its distributed containers.
118 
119     Args:
120         model (:obj:`torch.nn.Module`): The model to extract.
121 
122     Returns:
123         :obj:`torch.nn.Module`: The extracted model.
124     """
125     while isinstance(model, (torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)):
126         model = model.module
127     return model
128 
129 
130 def _tpu_gather(tensor, name="tensor"):
131     if isinstance(tensor, (list, tuple)):
132         return type(tensor)(_tpu_gather(t, name=f"{name}_{i}") for i, t in enumerate(tensor))
133     elif isinstance(tensor, dict):
134         return type(tensor)({k: _tpu_gather(v, name=f"{name}_{k}") for k, v in tensor.items()})
135     elif not isinstance(tensor, torch.Tensor):
136         raise TypeError(f"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.")
137     return xm.mesh_reduce(name, tensor, torch.cat)
138 
139 
140 def _gpu_gather(tensor):
141     if isinstance(tensor, (list, tuple)):
142         return type(tensor)(_gpu_gather(t) for t in tensor)
143     elif isinstance(tensor, dict):
144         return type(tensor)({k: _gpu_gather(v) for k, v in tensor.items()})
145     elif not isinstance(tensor, torch.Tensor):
146         raise TypeError(f"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.")
147     output_tensors = [tensor.clone() for _ in range(torch.distributed.get_world_size())]
148     torch.distributed.all_gather(output_tensors, tensor)
149     return torch.cat(output_tensors, dim=0)
150 
151 
152 def gather(tensor):
153     """
154     Recusrively gather tensor in a nested list/tuple/dictionary of tensors from all devices.
155 
156     Args:
157         tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):
158             The data to gather.
159 
160     Returns:
161         The same data structure as :obj:`tensor` with all tensors sent to the proper device.
162     """
163     if AcceleratorState().distributed_type == DistributedType.TPU:
164         return _tpu_gather(tensor, name="accelerate.utils.gather")
165     elif AcceleratorState().distributed_type == DistributedType.MULTI_GPU:
166         return _gpu_gather(tensor)
167     else:
168         return tensor
169 
170 
171 def wait_for_everyone():
172     """
173     Introduces a blocking point in the script, making sure all processes have reached this point before continuing.
174 
175     Warning::
176 
177         Make sure all processes will reach this instruction otherwise one of your processes will hang forever.
178     """
179     if AcceleratorState().distributed_type == DistributedType.MULTI_GPU:
180         torch.distributed.barrier()
181     elif AcceleratorState().distributed_type == DistributedType.TPU:
182         xm.rendezvous("accelerate.utils.wait_for_everyone")
183 
184 
185 def save(obj, f):
186     """
187     Save the data to disk. Use in place of :obj:`torch.save()`.
188 
189     Args:
190         obj: The data to save
191         f: The file (or file-like object) to use to save the data
192     """
193     if AcceleratorState().distributed_type == DistributedType.TPU:
194         xm.save(obj, f)
195     elif AcceleratorState().local_process_index == 0:
196         torch.save(obj, f)
197
```
--- 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()

```

diff --git a/src/accelerate/utils.py b/src/accelerate/utils.py
--- a/src/accelerate/utils.py
+++ b/src/accelerate/utils.py
@@ -105,10 +105,7 @@
     elif isinstance(tensor, dict):
         return type(tensor)({k: send_to_device(v, device) for k, v in tensor.items()})
     elif not hasattr(tensor, "to"):
-        raise TypeError(
-            f"Can't send the values of type {type(tensor)} to device {device}, only of nested list/tuple/dicts "
-            "of tensors or objects having a `to` method."
-        )
+        return tensor
     return tensor.to(device)

{"golden_diff": "diff --git a/src/accelerate/utils.py b/src/accelerate/utils.py\n--- a/src/accelerate/utils.py\n+++ b/src/accelerate/utils.py\n@@ -105,10 +105,7 @@\n     elif isinstance(tensor, dict):\n         return type(tensor)({k: send_to_device(v, device) for k, v in tensor.items()})\n     elif not hasattr(tensor, \"to\"):\n-        raise TypeError(\n-            f\"Can't send the values of type {type(tensor)} to device {device}, only of nested list/tuple/dicts \"\n-            \"of tensors or objects having a `to` method.\"\n-        )\n+        return tensor\n     return tensor.to(device)\n", "issue": "Can't send the values of int to device\nMy training data looks like:\r\n\r\nsrc_image, target_image, src_camera, target_camera, src_camera_idx, target_camera_idx\r\n\r\nWhere src_camera_idx, target_camera_idx are integers\r\n\r\nWhen I try to apply accelerate I get the following error:\r\nTypeError: Can't send the values of type <class 'int'> to device cuda:0, only of nested list/tuple/dicts of tensors or objects having a `to` method.\r\n\r\nWe don't need to send the integers to the device. Perhaps instead of raising an error here, you can simply skip the items that cannot be moved to device? Or at least give me the option to skip them if I know my data has such objects.\r\n\n", "before_files": [{"content": "# Copyright 2021 The HuggingFace Team. 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\nimport random\nfrom enum import Enum\nfrom typing import List, Optional, Union\n\nimport numpy as np\nimport torch\n\nfrom .state import AcceleratorState, DistributedType, is_tpu_available\n\n\nif is_tpu_available():\n    import torch_xla.core.xla_model as xm\n\n\nclass RNGType(Enum):\n    TORCH = \"torch\"\n    CUDA = \"cuda\"\n    XLA = \"xla\"\n    GENERATOR = \"generator\"\n\n\ndef set_seed(seed: int):\n    \"\"\"\n    Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch``.\n\n    Args:\n        seed (:obj:`int`): The seed to set.\n    \"\"\"\n    random.seed(seed)\n    np.random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    # ^^ safe to call this function even if cuda is not available\n    if is_tpu_available():\n        xm.set_rng_state(seed)\n\n\ndef synchronize_rng_state(rng_type: Optional[RNGType] = None, generator: Optional[torch.Generator] = None):\n    # Get the proper rng state\n    if rng_type == RNGType.TORCH:\n        rng_state = torch.get_rng_state()\n    elif rng_type == RNGType.CUDA:\n        rng_state = torch.cuda.get_rng_state()\n    elif rng_type == RNGType.XLA:\n        assert is_tpu_available(), \"Can't synchronize XLA seeds on an environment without TPUs.\"\n        rng_state = torch.tensor(xm.get_rng_state())\n    elif rng_type == RNGType.GENERATOR:\n        assert generator is not None, \"Need a generator to synchronize its seed.\"\n        rng_state = generator.get_state()\n\n    # Broadcast the rng state from device 0 to other devices\n    state = AcceleratorState()\n    if state.distributed_type == DistributedType.TPU:\n        rng_state = xm.mesh_reduce(\"random_seed\", rng_state, lambda x: x[0])\n    elif state.distributed_type == DistributedType.MULTI_GPU:\n        rng_state = rng_state.to(state.device)\n        torch.distributed.broadcast(rng_state, 0)\n        rng_state = rng_state.cpu()\n\n    # Set the broadcast rng state\n    if rng_type == RNGType.TORCH:\n        torch.set_rng_state(rng_state)\n    elif rng_type == RNGType.CUDA:\n        torch.cuda.set_rng_state(rng_state)\n    elif rng_type == RNGType.XLA:\n        xm.set_rng_state(rng_state.item())\n    elif rng_type == RNGType.GENERATOR:\n        generator.set_state(rng_state)\n\n\ndef synchronize_rng_states(rng_types: List[Union[str, RNGType]], generator: Optional[torch.Generator] = None):\n    for rng_type in rng_types:\n        synchronize_rng_state(RNGType(rng_type), generator=generator)\n\n\ndef send_to_device(tensor, device):\n    \"\"\"\n    Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.\n\n    Args:\n        tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):\n            The data to send to a given device.\n        device (:obj:`torch.device`):\n            The device to send the data to\n\n    Returns:\n        The same data structure as :obj:`tensor` with all tensors sent to the proper device.\n    \"\"\"\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(send_to_device(t, device) for t in tensor)\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: send_to_device(v, device) for k, v in tensor.items()})\n    elif not hasattr(tensor, \"to\"):\n        raise TypeError(\n            f\"Can't send the values of type {type(tensor)} to device {device}, only of nested list/tuple/dicts \"\n            \"of tensors or objects having a `to` method.\"\n        )\n    return tensor.to(device)\n\n\ndef extract_model_from_parallel(model):\n    \"\"\"\n    Extract a model from its distributed containers.\n\n    Args:\n        model (:obj:`torch.nn.Module`): The model to extract.\n\n    Returns:\n        :obj:`torch.nn.Module`: The extracted model.\n    \"\"\"\n    while isinstance(model, (torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)):\n        model = model.module\n    return model\n\n\ndef _tpu_gather(tensor, name=\"tensor\"):\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(_tpu_gather(t, name=f\"{name}_{i}\") for i, t in enumerate(tensor))\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: _tpu_gather(v, name=f\"{name}_{k}\") for k, v in tensor.items()})\n    elif not isinstance(tensor, torch.Tensor):\n        raise TypeError(f\"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.\")\n    return xm.mesh_reduce(name, tensor, torch.cat)\n\n\ndef _gpu_gather(tensor):\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(_gpu_gather(t) for t in tensor)\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: _gpu_gather(v) for k, v in tensor.items()})\n    elif not isinstance(tensor, torch.Tensor):\n        raise TypeError(f\"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.\")\n    output_tensors = [tensor.clone() for _ in range(torch.distributed.get_world_size())]\n    torch.distributed.all_gather(output_tensors, tensor)\n    return torch.cat(output_tensors, dim=0)\n\n\ndef gather(tensor):\n    \"\"\"\n    Recusrively gather tensor in a nested list/tuple/dictionary of tensors from all devices.\n\n    Args:\n        tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):\n            The data to gather.\n\n    Returns:\n        The same data structure as :obj:`tensor` with all tensors sent to the proper device.\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.TPU:\n        return _tpu_gather(tensor, name=\"accelerate.utils.gather\")\n    elif AcceleratorState().distributed_type == DistributedType.MULTI_GPU:\n        return _gpu_gather(tensor)\n    else:\n        return tensor\n\n\ndef wait_for_everyone():\n    \"\"\"\n    Introduces a blocking point in the script, making sure all processes have reached this point before continuing.\n\n    Warning::\n\n        Make sure all processes will reach this instruction otherwise one of your processes will hang forever.\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.MULTI_GPU:\n        torch.distributed.barrier()\n    elif AcceleratorState().distributed_type == DistributedType.TPU:\n        xm.rendezvous(\"accelerate.utils.wait_for_everyone\")\n\n\ndef save(obj, f):\n    \"\"\"\n    Save the data to disk. Use in place of :obj:`torch.save()`.\n\n    Args:\n        obj: The data to save\n        f: The file (or file-like object) to use to save the data\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.TPU:\n        xm.save(obj, f)\n    elif AcceleratorState().local_process_index == 0:\n        torch.save(obj, f)\n", "path": "src/accelerate/utils.py"}], "after_files": [{"content": "# Copyright 2021 The HuggingFace Team. 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\nimport random\nfrom enum import Enum\nfrom typing import List, Optional, Union\n\nimport numpy as np\nimport torch\n\nfrom .state import AcceleratorState, DistributedType, is_tpu_available\n\n\nif is_tpu_available():\n    import torch_xla.core.xla_model as xm\n\n\nclass RNGType(Enum):\n    TORCH = \"torch\"\n    CUDA = \"cuda\"\n    XLA = \"xla\"\n    GENERATOR = \"generator\"\n\n\ndef set_seed(seed: int):\n    \"\"\"\n    Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch``.\n\n    Args:\n        seed (:obj:`int`): The seed to set.\n    \"\"\"\n    random.seed(seed)\n    np.random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    # ^^ safe to call this function even if cuda is not available\n    if is_tpu_available():\n        xm.set_rng_state(seed)\n\n\ndef synchronize_rng_state(rng_type: Optional[RNGType] = None, generator: Optional[torch.Generator] = None):\n    # Get the proper rng state\n    if rng_type == RNGType.TORCH:\n        rng_state = torch.get_rng_state()\n    elif rng_type == RNGType.CUDA:\n        rng_state = torch.cuda.get_rng_state()\n    elif rng_type == RNGType.XLA:\n        assert is_tpu_available(), \"Can't synchronize XLA seeds on an environment without TPUs.\"\n        rng_state = torch.tensor(xm.get_rng_state())\n    elif rng_type == RNGType.GENERATOR:\n        assert generator is not None, \"Need a generator to synchronize its seed.\"\n        rng_state = generator.get_state()\n\n    # Broadcast the rng state from device 0 to other devices\n    state = AcceleratorState()\n    if state.distributed_type == DistributedType.TPU:\n        rng_state = xm.mesh_reduce(\"random_seed\", rng_state, lambda x: x[0])\n    elif state.distributed_type == DistributedType.MULTI_GPU:\n        rng_state = rng_state.to(state.device)\n        torch.distributed.broadcast(rng_state, 0)\n        rng_state = rng_state.cpu()\n\n    # Set the broadcast rng state\n    if rng_type == RNGType.TORCH:\n        torch.set_rng_state(rng_state)\n    elif rng_type == RNGType.CUDA:\n        torch.cuda.set_rng_state(rng_state)\n    elif rng_type == RNGType.XLA:\n        xm.set_rng_state(rng_state.item())\n    elif rng_type == RNGType.GENERATOR:\n        generator.set_state(rng_state)\n\n\ndef synchronize_rng_states(rng_types: List[Union[str, RNGType]], generator: Optional[torch.Generator] = None):\n    for rng_type in rng_types:\n        synchronize_rng_state(RNGType(rng_type), generator=generator)\n\n\ndef send_to_device(tensor, device):\n    \"\"\"\n    Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.\n\n    Args:\n        tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):\n            The data to send to a given device.\n        device (:obj:`torch.device`):\n            The device to send the data to\n\n    Returns:\n        The same data structure as :obj:`tensor` with all tensors sent to the proper device.\n    \"\"\"\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(send_to_device(t, device) for t in tensor)\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: send_to_device(v, device) for k, v in tensor.items()})\n    elif not hasattr(tensor, \"to\"):\n        return tensor\n    return tensor.to(device)\n\n\ndef extract_model_from_parallel(model):\n    \"\"\"\n    Extract a model from its distributed containers.\n\n    Args:\n        model (:obj:`torch.nn.Module`): The model to extract.\n\n    Returns:\n        :obj:`torch.nn.Module`: The extracted model.\n    \"\"\"\n    while isinstance(model, (torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)):\n        model = model.module\n    return model\n\n\ndef _tpu_gather(tensor, name=\"tensor\"):\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(_tpu_gather(t, name=f\"{name}_{i}\") for i, t in enumerate(tensor))\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: _tpu_gather(v, name=f\"{name}_{k}\") for k, v in tensor.items()})\n    elif not isinstance(tensor, torch.Tensor):\n        raise TypeError(f\"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.\")\n    return xm.mesh_reduce(name, tensor, torch.cat)\n\n\ndef _gpu_gather(tensor):\n    if isinstance(tensor, (list, tuple)):\n        return type(tensor)(_gpu_gather(t) for t in tensor)\n    elif isinstance(tensor, dict):\n        return type(tensor)({k: _gpu_gather(v) for k, v in tensor.items()})\n    elif not isinstance(tensor, torch.Tensor):\n        raise TypeError(f\"Can't gather the values of type {type(tensor)}, only of nested list/tuple/dicts of tensors.\")\n    output_tensors = [tensor.clone() for _ in range(torch.distributed.get_world_size())]\n    torch.distributed.all_gather(output_tensors, tensor)\n    return torch.cat(output_tensors, dim=0)\n\n\ndef gather(tensor):\n    \"\"\"\n    Recusrively gather tensor in a nested list/tuple/dictionary of tensors from all devices.\n\n    Args:\n        tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):\n            The data to gather.\n\n    Returns:\n        The same data structure as :obj:`tensor` with all tensors sent to the proper device.\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.TPU:\n        return _tpu_gather(tensor, name=\"accelerate.utils.gather\")\n    elif AcceleratorState().distributed_type == DistributedType.MULTI_GPU:\n        return _gpu_gather(tensor)\n    else:\n        return tensor\n\n\ndef wait_for_everyone():\n    \"\"\"\n    Introduces a blocking point in the script, making sure all processes have reached this point before continuing.\n\n    Warning::\n\n        Make sure all processes will reach this instruction otherwise one of your processes will hang forever.\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.MULTI_GPU:\n        torch.distributed.barrier()\n    elif AcceleratorState().distributed_type == DistributedType.TPU:\n        xm.rendezvous(\"accelerate.utils.wait_for_everyone\")\n\n\ndef save(obj, f):\n    \"\"\"\n    Save the data to disk. Use in place of :obj:`torch.save()`.\n\n    Args:\n        obj: The data to save\n        f: The file (or file-like object) to use to save the data\n    \"\"\"\n    if AcceleratorState().distributed_type == DistributedType.TPU:\n        xm.save(obj, f)\n    elif AcceleratorState().local_process_index == 0:\n        torch.save(obj, f)\n", "path": "src/accelerate/utils.py"}]}