internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Lightning-Universe/lightning-flash

Issue:
ModuleNotFoundError: No module named 'icevision.backbones'
Using an example snippet from the README:
Icevision is the latest version from GitHub master.

![image](https://user-images.githubusercontent.com/4758917/170154700-8077d278-2569-4774-af07-d8fd70a8f611.png)
![image](https://user-images.githubusercontent.com/4758917/170154662-62a15922-44c0-4838-93d9-865cccf1e076.png)


Discussion:
Hey! I took a look and it looks like the problem is with python 3.10, when downgraded to 3.7 more package versions are available and the dependencies are resolved.
In python 3.10 I was not able to install valid torch version due to some problems with torchvision/torchaudio, and got this type of error:
```
    icevision[all] 0.12.0 depends on torch<1.11 and >=1.9.0
    icevision[all] 0.11.0 depends on torch<1.11 and >=1.9.0
    icevision[all] 0.8.1 depends on torch<1.9 and >=1.7.0
    icevision[all] 0.8.0 depends on torch<1.9 and >=1.7.0
```
After downgrade, it works fine. 

The question is what next with that problem, probably depends on support version of python in lightning-flash

Readme says we support 3.10, so we should handle it somehow, for example give additional conditional on icedata/icevision to use them in specific case, or allow using them with 3.10 (it could be blocker due to some dependencies in other packages).

I can dive deeper with this problem next week. If someone wants to take care of this sooner, it is welcome

https://github.com/pytorch/pytorch/issues/66424 is still open, do we really support python 3.10 if pytorch does not? 

Hey @roboserg thanks for brining this to our attention and @plutasnyy thanks for your investigation! It sounds like the correct solution here is to refine our list of support Python versions, in fact I think we should only claim to support 3.7 - 3.9 as these are the versions we test against. 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -99,7 +99,7 @@ def _expand_reqs(extras: dict, keys: list) -> list:
     },
     zip_safe=False,
     keywords=["deep learning", "pytorch", "AI"],
-    python_requires=">=3.6",
+    python_requires=">=3.7",
     install_requires=base_req,
     project_urls={
         "Bug Tracker": "https://github.com/PyTorchLightning/lightning-flash/issues",
@@ -123,10 +123,8 @@ def _expand_reqs(extras: dict, keys: list) -> list:
         # Specify the Python versions you support here. In particular, ensure
         # that you indicate whether you support Python 2, Python 3 or both.
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
-        "Programming Language :: Python :: 3.10",
     ],
 )


Test patch:
Repository: Lightning-Universe/lightning-flash

Issue:
Revisit TPU training
## 🚀 Feature

just curious, have you used TPU on Kaggle recently?
https://www.kaggle.com/code/jirkaborovec/demo-flash-image-classification-on-tpu

### Motivation

Kaggle has offered 20 hours of training which is mostly used with TF of Keras as any other lib is rather difficult, so there is huge potential to take this space by Flash...
Also With Flash, it shall be trivial to start your work with CPU for exploration and then alternate between GPU and TPU offering to finish with the best-trained model :rabbit: 

### Pitch

<!-- A clear and concise description of what you want to happen. -->

### Alternatives

Reason: https://pytorch-lightning.readthedocs.io/en/latest/accelerators/tpu_faq.html#unsupported-datatype-transfer-to-tpus

Unsupported data type transfer to TPUs?
```
File "/usr/local/lib/python3.8/dist-packages/torch_xla/utils/utils.py", line 205, in _for_each_instance_rewrite
    v = _for_each_instance_rewrite(result.__dict__[k], select_fn, fn, rwmap)
File "/usr/local/lib/python3.8/dist-packages/torch_xla/utils/utils.py", line 206, in _for_each_instance_rewrite
    result.__dict__[k] = v
TypeError: 'mappingproxy' object does not support item assignment
```

### Additional context

<!-- Add any other context or screenshots about the feature request here. -->



Discussion:
i have the same issue on tpu! env:
- Python 3.7.10
- pytorch 1.9.1

Resolving patch:
diff --git a/flash/core/data/io/input.py b/flash/core/data/io/input.py
--- a/flash/core/data/io/input.py
+++ b/flash/core/data/io/input.py
@@ -15,6 +15,7 @@
 import os
 import sys
 from copy import deepcopy
+from enum import Enum
 from typing import Any, cast, Dict, Iterable, List, Sequence, Tuple, Union
 
 from pytorch_lightning.utilities.enums import LightningEnum
@@ -171,7 +172,18 @@ def __init__(self, running_stage: RunningStage, *args: Any, **kwargs: Any) -> No
 
     def _call_load_sample(self, sample: Any) -> Any:
         # Deepcopy the sample to avoid leaks with complex data structures
-        return getattr(self, f"{_STAGES_PREFIX[self.running_stage]}_load_sample")(deepcopy(sample))
+        sample_output = getattr(self, f"{_STAGES_PREFIX[self.running_stage]}_load_sample")(deepcopy(sample))
+
+        # Change DataKeys Enum to strings
+        if isinstance(sample_output, dict):
+            output_dict = {}
+            for key, val in sample_output.items():
+                if isinstance(key, Enum) and hasattr(key, "value"):
+                    output_dict[key.value] = val
+                else:
+                    output_dict[key] = val
+            return output_dict
+        return sample_output
 
     @staticmethod
     def load_data(*args: Any, **kwargs: Any) -> Union[Sequence, Iterable]:


Test patch:
Repository: Lightning-Universe/lightning-flash

Issue:
The type of `n_gram` is mislabeled as bool, which should be int type.
## 🐛 Bug

In Translation Task:
The type of `n_gram` is mislabeled as bool, which should be int type.

### To Reproduce

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
```
flash translation from_hf_datasets --help
```
The error raised:
```
translation: error: Configuration check failed :: Parser key "model.n_gram": Expected a <class 'bool'> but got "4"
```



Discussion:

Resolving patch:
diff --git a/flash/text/seq2seq/translation/model.py b/flash/text/seq2seq/translation/model.py
--- a/flash/text/seq2seq/translation/model.py
+++ b/flash/text/seq2seq/translation/model.py
@@ -58,7 +58,7 @@ def __init__(
         metrics: METRICS_TYPE = None,
         learning_rate: Optional[float] = None,
         num_beams: Optional[int] = 4,
-        n_gram: bool = 4,
+        n_gram: int = 4,
         smooth: bool = True,
         enable_ort: bool = False,
     ):


Test patch:
Repository: Lightning-Universe/lightning-flash

Issue:
`ObjectDetectionData.from_images` raise an error
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

after pass the datamodule into finetune, at the end of the epoch it throws an error message:

```
/opt/conda/lib/python3.7/site-packages/flash/core/data/utilities/classification.py in _strip(x)
     44 
     45 def _strip(x: str) -> str:
---> 46     return x.strip(", ")
     47 
     48 

AttributeError: 'int' object has no attribute 'strip'

```
### To Reproduce

#### Code sample

datamodule snipset code was from documentation

```py
from flash.image import ObjectDetectionData, ObjectDetector
from PIL import Image
import numpy as np
from flash import Trainer

datamodule = ObjectDetectionData.from_images(
    train_images=[
        Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8")),
         Image.fromarray(np.random.randint(0, 255,(512, 512, 3), dtype="uint8")),
         Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8")),
    ],
         train_targets=[["cat"], ["cat"], ["cat"]],
     train_bboxes=[
         [{"xmin": 10, "ymin": 20, "width": 5, "height": 10}],
         [{"xmin": 20, "ymin": 30, "width": 10, "height": 10}],
         [{"xmin": 10, "ymin": 20, "width": 5, "height": 25}],
     ],
     predict_images=[Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8"))],
     transform_kwargs=dict(image_size=(512, 512)),
     batch_size=2,
 )

model=ObjectDetector(
                        head="efficientdet", 
                        backbone="d0",
                        image_size=512,
                        labels=datamodule.labels,

                    )

trainer = Trainer(max_epochs=20,accelerator="gpu")
trainer.finetune(model, datamodule=datamodule, strategy="freeze")

```
### Expected behavior

It should not throw an error after the end of an epoch

### Environment

 - OS (e.g., Linux): Ubuntu
 - Python version: 3.7.111
 - PyTorch/Lightning/Flash Version : pytorch-lightning==1.7.0,  lightning-flash==0.8.0
 - GPU models and configuration: Quadro T2000, Cuda Version 11.4




Discussion:

Resolving patch:
diff --git a/src/flash/core/data/utilities/classification.py b/src/flash/core/data/utilities/classification.py
--- a/src/flash/core/data/utilities/classification.py
+++ b/src/flash/core/data/utilities/classification.py
@@ -42,8 +42,11 @@ def _as_list(x: Union[List, Tensor, np.ndarray]) -> List:
     return x
 
 
-def _strip(x: str) -> str:
-    return x.strip(", ")
+def _strip(x: Union[str, int]) -> str:
+    """Replace both ` ` and `,` from str."""
+    if isinstance(x, str):
+        return x.strip(", ")
+    return str(x)
 
 
 @dataclass


Test patch:
Repository: sony/model_optimization

Issue:
MCT fails for "dims" parameter of type List in torch.permute
### Issue Type

Bug

### Source

source

### MCT Version

nightly

### OS Platform and Distribution

_No response_

### Python version

_No response_

### Describe the issue

```shell
the dims parameter is a list which fails MCT
x = torch.permute(x, [0, 2, 3, 1])
switching to a tuple works fine
x = torch.permute(x, (0, 2, 3, 1))
```


### Expected behaviour

_No response_

### Code to reproduce the issue

```shell
import torch
import torch.nn as nn
import torch.nn.functional as F
import model_compression_toolkit as mct


class BugNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Conv2d(3, 6, 5)
        self.fc = nn.Linear(216, 2)

    def forward(self, x):
        x = F.relu(self.conv(x))
        x = torch.permute(x, [0, 2, 3, 1])
        x = torch.reshape(x, [-1, 216])
        x = self.fc(x)
        return x


def rep_dataset():
    yield [torch.zeros(16, 3, 10, 10)]


model = BugNet()

# forward pass works
model(torch.zeros(16, 3, 10, 10))

mct.ptq.pytorch_post_training_quantization_experimental(model, rep_dataset)
```


### Log output

```shell
File ".../model_optimization/model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py", line 98, in _run_operation
    out_tensors_of_n_float = op_func(*input_tensors + op_call_args, **functional_kwargs)
TypeError: permute(): argument 'dims' (position 2) must be tuple of ints, but found element of type immutable_list at pos 0
```



Discussion:

Resolving patch:
diff --git a/model_compression_toolkit/core/pytorch/reader/graph_builders.py b/model_compression_toolkit/core/pytorch/reader/graph_builders.py
--- a/model_compression_toolkit/core/pytorch/reader/graph_builders.py
+++ b/model_compression_toolkit/core/pytorch/reader/graph_builders.py
@@ -188,6 +188,9 @@ def nodes_builder(model: GraphModule,
 
             # remove torch.fx.node.Node from inputs to graph_node_type
             op_call_args = [arg for arg in op_call_args if not isinstance(arg, Node)]
+            # convert torch.fx.immutable_collections.immutable_list to tuple
+            op_call_args = [tuple(arg) if isinstance(arg, torch.fx.immutable_collections.immutable_list) else arg
+                            for arg in op_call_args]
 
             kwargs = {FUNCTIONAL_OP: node_type,
                       OP_CALL_ARGS: op_call_args,


Test patch:
Repository: scikit-hep/awkward

Issue:
TypeError when introspecting ak.highlevel.Record
I see the following TypeError when calling `dir()`  on instances of `ak.highlevel.Record`:

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-fb278c25e68f> in <module>
----> 1 dir(rec)

~/miniconda3/envs/awkward/lib/python3.8/site-packages/awkward1/highlevel.py in __dir__(self)
   1620         that can be accessed as attributes.
   1621         """
-> 1622         return sorted(set(dir(super(Array, self))
   1623                           + [x for x in self._layout.keys()
   1624                                if _dir_pattern.match(x) and

TypeError: super(type, obj): obj must be an instance or subtype of type
```

I can reproduce the exception by running the following snippet on:
* macOS 10.15.4, Python 3.8.2, awkward1==0.2.10
* Ubuntu 18.04, Python 3.7.4, awkward1==0.2.10

```python
import awkward1 as ak

# Introspecting the class is fine
dir(ak.highlevel.Record)

rec = ak.from_iter({
    'numbers': [1, 2, 3],
    'letters': ['a', 'b', 'c'],
})

# Introspecting an instance raises TypeError
dir(rec)
```

The traceback leads me to the implementation of `Record.__dir__`:
https://github.com/scikit-hep/awkward-1.0/blob/8215351f09de3773b14318815538ec0faaeb6235/src/awkward1/highlevel.py#L1617-L1625

I think the issue can be fixed by changing the first argument in the call to `super()` from Array to Record, but in case I'm not seeing something I defer to the authors on what the passed type should be.


Discussion:

Resolving patch:
diff --git a/src/awkward1/highlevel.py b/src/awkward1/highlevel.py
--- a/src/awkward1/highlevel.py
+++ b/src/awkward1/highlevel.py
@@ -1619,7 +1619,7 @@ def __dir__(self):
         Lists all methods, properties, and field names (see #__getattr__)
         that can be accessed as attributes.
         """
-        return sorted(set(dir(super(Array, self))
+        return sorted(set(dir(super(Record, self))
                           + [x for x in self._layout.keys()
                                if _dir_pattern.match(x) and
                                not keyword.iskeyword(x)]))


Test patch:
Repository: scikit-hep/awkward

Issue:
release tarball is missing files
The current release tarball
https://files.pythonhosted.org/packages/24/81/9798b934e4c9313abb5d4ffe8af86f7a5cf87eb873de463b294813518eea/awkward1-0.2.11.tar.gz
is missing requirements-docs.txt and requirements-dev.txt, which are still required by setup.py
release tarball is missing files
The current release tarball
https://files.pythonhosted.org/packages/24/81/9798b934e4c9313abb5d4ffe8af86f7a5cf87eb873de463b294813518eea/awkward1-0.2.11.tar.gz
is missing requirements-docs.txt and requirements-dev.txt, which are still required by setup.py


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,8 +18,10 @@
 install_requires = open("requirements.txt").read().strip().split()
 
 extras = {"test": open("requirements-test.txt").read().strip().split(),
-          "docs": open("requirements-docs.txt").read().strip().split(),
-          "dev":  open("requirements-dev.txt").read().strip().split()}
+          "dev":  ['numba>=0.46.0;python_version>="3"',
+                   'pandas>=0.24.0;python_version>="3"',
+                   'numexpr;python_version>="3"',
+                   'autograd;python_version>="3"']}
 extras["all"] = sum(extras.values(), [])
 
 tests_require = extras["test"]


Test patch:
Repository: scikit-hep/awkward

Issue:
RuntimeError when seting a field to virtual
Python code to reproduce:
```
import awkward1 as ak
a = ak.Array({"x": [1]})
a["y"] = ak.virtual(lambda: [2], cache={}, length=1)
print(a)
```
The last line raises the following error:
`RuntimeError: PyArrayCache has lost its weak reference to mapping`
The error only appears if the length and cache parameters are supplied.
Tested on awkward1 0.4.5


Discussion:

Resolving patch:
diff --git a/src/awkward1/highlevel.py b/src/awkward1/highlevel.py
--- a/src/awkward1/highlevel.py
+++ b/src/awkward1/highlevel.py
@@ -1022,9 +1022,11 @@ def __setitem__(self, where, what):
                 "only fields may be assigned in-place (by field name)"
                 + awkward1._util.exception_suffix(__file__)
             )
-        self._layout = awkward1.operations.structure.with_field(
+        array = awkward1.operations.structure.with_field(
             self._layout, what, where
-        ).layout
+        )
+        self._layout = array.layout
+        self._caches = awkward1._util.find_caches(self._layout)
         self._numbaview = None
 
     def __getattr__(self, where):
@@ -1752,9 +1754,11 @@ def __setitem__(self, where, what):
                 "only fields may be assigned in-place (by field name)"
                 + awkward1._util.exception_suffix(__file__)
             )
-        self._layout = awkward1.operations.structure.with_field(
+        array = awkward1.operations.structure.with_field(
             self._layout, what, where
-        ).layout
+        )
+        self._layout = array.layout
+        self._caches = awkward1._util.find_caches(self._layout)
         self._numbaview = None
 
     def __getattr__(self, where):
diff --git a/src/awkward1/operations/structure.py b/src/awkward1/operations/structure.py
--- a/src/awkward1/operations/structure.py
+++ b/src/awkward1/operations/structure.py
@@ -603,6 +603,9 @@ def with_field(base, what, where=None, right_broadcast=False, highlevel=True):
     other.)
     """
 
+    if isinstance(what, (awkward1.highlevel.Array, awkward1.highlevel.Record)):
+        what_caches = what.caches
+
     if not (
         where is None
         or isinstance(where, str)


Test patch:
diff --git a/tests/test_0560-setting-virtual-field.py b/tests/test_0560-setting-virtual-field.py
new file mode 100644
--- /dev/null
+++ b/tests/test_0560-setting-virtual-field.py
@@ -0,0 +1,20 @@
+# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/master/LICENSE
+
+from __future__ import absolute_import
+
+import sys
+
+import pytest
+
+import numpy
+import awkward1
+
+
+def test():
+    array = awkward1.Array([{"x": 1}])
+    array["y"] = awkward1.virtual(lambda: [2], cache={}, length=1)
+
+    print("NOW", type(array.caches[0]), id(array.caches[0]))
+
+
+    awkward1.to_list(array)
Repository: scikit-hep/awkward

Issue:
to_arrow() fails with IrregularlyPartitionedArrays
This came up while using `uproot.lazy()`:

```python
>>> import awkward as ak
>>> ak.__version__
'1.0.2'
>>> import uproot
>>> ak.to_arrow(uproot.lazy('file.root'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/miniconda3/envs/iris-hep/lib/python3.9/site-packages/awkward/operations/convert.py", line 2226, in to_arrow
    return recurse(layout, None, False)
  File "/home/user/miniconda3/envs/iris-hep/lib/python3.9/site-packages/awkward/operations/convert.py", line 2221, in recurse
    raise TypeError(
TypeError: unrecognized array type: <IrregularlyPartitionedArray>
```


Discussion:

Resolving patch:
diff --git a/src/awkward/operations/convert.py b/src/awkward/operations/convert.py
--- a/src/awkward/operations/convert.py
+++ b/src/awkward/operations/convert.py
@@ -2453,6 +2453,11 @@ def recurse(layout, mask, is_option):
         elif isinstance(layout, (ak.layout.VirtualArray)):
             return recurse(layout.array, None, False)
 
+        elif isinstance(layout, (ak.partition.PartitionedArray)):
+            return pyarrow.chunked_array(
+                [recurse(x, None, False) for x in layout.partitions]
+            )
+
         else:
             raise TypeError(
                 "unrecognized array type: {0}".format(repr(layout))


Test patch:
diff --git a/tests/test_0702-partitioned-to-arrow.py b/tests/test_0702-partitioned-to-arrow.py
new file mode 100644
--- /dev/null
+++ b/tests/test_0702-partitioned-to-arrow.py
@@ -0,0 +1,17 @@
+# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
+
+from __future__ import absolute_import
+
+import pytest  # noqa: F401
+import numpy as np  # noqa: F401
+import awkward as ak  # noqa: F401
+
+
+pyarrow = pytest.importorskip("pyarrow")
+
+
+def test():
+    array = ak.repartition(ak.Array(range(10)), [3, 3, 3, 1])
+    arrow = ak.to_arrow(array)
+    assert isinstance(arrow, pyarrow.ChunkedArray)
+    assert arrow.to_pylist() == list(range(10))
Repository: scikit-hep/awkward

Issue:
Concatenation of arrays with different dimensions at axis=1
Even if it's not allowed, it shouldn't return _this_ error:

```python
>>> ak.concatenate([ak.Array([[1, 2, 3], [], [4, 5]]), ak.Array([100, 200, 300])], axis=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jpivarski/irishep/awkward-1.0/awkward/operations/structure.py", line 1379, in concatenate
    out = ak._util.broadcast_and_apply(
  File "/home/jpivarski/irishep/awkward-1.0/awkward/_util.py", line 1026, in broadcast_and_apply
    out = apply(broadcast_pack(inputs, isscalar), 0, user)
  File "/home/jpivarski/irishep/awkward-1.0/awkward/_util.py", line 786, in apply
    outcontent = apply(nextinputs, depth + 1, user)
  File "/home/jpivarski/irishep/awkward-1.0/awkward/_util.py", line 838, in apply
    outcontent = apply(nextinputs, depth + 1, user)
  File "/home/jpivarski/irishep/awkward-1.0/awkward/_util.py", line 974, in apply
    raise ValueError(
ValueError: cannot broadcast: <class 'awkward._ext.NumpyArray'>, <class 'awkward._ext.NumpyArray'>

(https://github.com/scikit-hep/awkward-1.0/blob/1.1.0/src/awkward/_util.py#L976)
```


Discussion:

Resolving patch:
diff --git a/src/awkward/operations/structure.py b/src/awkward/operations/structure.py
--- a/src/awkward/operations/structure.py
+++ b/src/awkward/operations/structure.py
@@ -1591,6 +1591,16 @@ def getfunction(inputs, depth):
                 )
                 return lambda: (out,)
 
+            elif any(
+                x.minmax_depth == (1, 1)
+                for x in inputs
+                if isinstance(x, ak.layout.Content)
+            ):
+                raise ValueError(
+                    "at least one array is not deep enough to concatenate at "
+                    "axis={0}".format(axis) + ak._util.exception_suffix(__file__)
+                )
+
             else:
                 return None
 


Test patch: