Allow stateful function in dataset.map
COLLABORATOR
@lhoestq Added a test. If you can come up with a better stateful callable, I'm all ears 😄.  
2021-03-14T12:45:15Z
https://github.com/huggingface/datasets/pull/1960#issuecomment-798900803
https://api.github.com/repos/huggingface/datasets/issues/1960
MDEyOklzc3VlQ29tbWVudDc5ODkwMDgwMw==
https://api.github.com/repos/huggingface/datasets/issues/comments/798900803/reactions
2021-03-14T12:45:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/798900803
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
MEMBER
Sorry I said earlier that it was good to have it inside the loop, my mistake !
2021-03-15T18:46:02Z
https://github.com/huggingface/datasets/pull/1960#issuecomment-799664401
https://api.github.com/repos/huggingface/datasets/issues/1960
MDEyOklzc3VlQ29tbWVudDc5OTY2NDQwMQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/799664401/reactions
2021-03-15T18:46:02Z
https://api.github.com/repos/huggingface/datasets/issues/comments/799664401
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
@lhoestq Okay, did some refactoring and now the "cache" part comes before the for loop. Thanks for the guidance.

Think this is ready for the final review.
2021-03-23T14:34:20Z
https://github.com/huggingface/datasets/pull/1960#issuecomment-804953256
https://api.github.com/repos/huggingface/datasets/issues/1960
MDEyOklzc3VlQ29tbWVudDgwNDk1MzI1Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/804953256/reactions
2021-03-23T14:34:20Z
https://api.github.com/repos/huggingface/datasets/issues/comments/804953256
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
Removes the "test type" section in Dataset.map which would modify the state of the stateful function. Now, the return type of the map function is inferred after processing the first example.

Fixes #1940 

@lhoestq Not very happy with the usage of `nonlocal`. Would like to hear your opinion on this.